我刚刚初始化了一个新的 Spring Boot 应用程序,并且我build.gradle有以下依赖项:dependencies { implementation 'org.springframework.boot:spring-boot-starter-web' providedRuntime 'org.springframework.boot:spring-boot-starter-undertow' testImplementation 'org.springframework.boot:spring-boot-starter-test'}当我运行时./gradlew bootRun,它正在使用 Tomcat。我知道starter-web包括 Tomcat,但没有providedRuntime覆盖它吗?我如何实际使用 undertow 来运行我的 Spring 控制器?编辑:我刚刚意识到我的ServletInitializer.java样子是这样的:import org.springframework.boot.builder.SpringApplicationBuilder;import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;public class ServletInitializer extends SpringBootServletInitializer { @Override protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { return application.sources(AccountServiceApplication.class); }}这告诉我它正在初始化一个 servlet,我假设它是undertow基于依赖关系的,但我错了吗?
1 回答
潇湘沐
TA贡献1816条经验 获得超6个赞
您需要从构建中排除 tomcat:
dependencies {
implementation ('org.springframework.boot:spring-boot-starter-web') {
exclude module: 'spring-boot-starter-tomcat'
}
providedRuntime 'org.springframework.boot:spring-boot-starter-undertow'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
添加回答
举报
0/150
提交
取消