为了账号安全,请及时绑定邮箱和手机立即绑定

在 `build.gradle` 中提供了运行时`spring-boot-starter-

在 `build.gradle` 中提供了运行时`spring-boot-starter-

收到一只叮咚 2022-07-27 09:22:38
我刚刚初始化了一个新的 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'

}


查看完整回答
反对 回复 2022-07-27
  • 1 回答
  • 0 关注
  • 88 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信