亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

在 `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 關注
  • 127 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號