如何在 spring boot 应用程序中更改服务器?

新手上路,请多包涵

我的项目要求是使用其他服务器而不是tomcat?我们如何从 spring boot 应用程序更改嵌入式服务器?

原文由 Vikram Shekhawat 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 815
1 个回答

您将需要更新 pom.xml ,添加 spring-boot-starter-jetty 的依赖项。此外,您将需要 exclude 默认添加 spring-boot-starter-tomcat 依赖项。

 <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
    <exclusions>
        <exclusion>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
        </exclusion>
    </exclusions>
</dependency>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-jetty</artifactId>
</dependency>

在渐变中,

 configurations {
    compile.exclude module: "spring-boot-starter-tomcat"
}

dependencies {
    compile("org.springframework.boot:spring-boot-starter-web")
    compile("org.springframework.boot:spring-boot-starter-jetty")
}

原文由 Thirumal 发布,翻译遵循 CC BY-SA 4.0 许可协议

推荐问题