Search code examples
springspring-bootspring-webfluxgraphql-java

Deploying Webflux application Jar file


I have created Graphql application with Spring Boot Webflux. I am pretty new to this. Can some one please tell me the process of deployment of same. I know about traditional tomcat deployment but i read that using that, it removes of the features.


Solution

  • There are two ways you could deploy a spring-boot application.

    • Running as a standalone JAR file
    • Deploy as a WAR file into a tomcat (For Spring WebFlux application this is not supported).

    Deploy as a standalone JAR

    To generate an executable JAR we could either use spring-boot maven plugin or spring-boot gradle plugin depending on your use case.

    Spring Boot Maven Plugin

    • Add following to the pom.xml.
    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
    
    • Run following command to generate the executable.
    mvn clean package spring-boot:repackage
    
    • Then run the generated JAR file with following command.
    java -jar <path-to-generated-jar>/<app-name>.jar
    

    Spring Boot Gradle Plugin

    • Run following command to generate the executable.
    ./gradlew bootJar
    
    • Then run the generated JAR file with following command.
    java -jar <path-to-generated-jar>/<app-name>.jar