【问题标题】:Deploying Webflux application Jar file部署 Webflux 应用程序 Jar 文件
【发布时间】:2022-06-10 21:00:01
【问题描述】:

我已经使用 Spring Boot Webflux 创建了 Graphql 应用程序。我对此很陌生。有人可以告诉我部署相同的过程。我知道传统的 tomcat 部署,但我读到使用它,它删除了这些功能。

【问题讨论】:

  • 请提供足够的代码,以便其他人更好地理解或重现问题。

标签: spring spring-boot spring-webflux graphql-java


【解决方案1】:

有两种方法可以部署 spring-boot 应用程序。

  • 作为独立 JAR 文件运行
  • 作为 WAR 文件部署到 tomcat 中(对于 Spring WebFlux 应用程序,这不是 supported)。

部署为独立的 JAR

要生成可执行 JAR,我们可以使用 spring-boot maven plugin 或 spring-boot gradle plugin,具体取决于您的用例。

Spring Boot Maven 插件

  • 将关注添加到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>
  • 运行以下命令生成可执行文件。
mvn clean package spring-boot:repackage
  • 然后使用以下命令运行生成的 JAR 文件。
java -jar <path-to-generated-jar>/<app-name>.jar

Spring Boot Gradle 插件

  • 运行以下命令生成可执行文件。
./gradlew bootJar
  • 然后使用以下命令运行生成的 JAR 文件。
java -jar <path-to-generated-jar>/<app-name>.jar

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-12-14
    • 2016-06-06
    • 2019-07-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-07-29
    相关资源
    最近更新 更多