обеспечил выполнение `spring-boot-starter-undertow` в` build.gradle`, но `: bootRun` все еще использует Tomcat вместо undertow - PullRequest
0 голосов
/ 09 марта 2019

Я только что инициализировал новое приложение 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?

EDIT:

Я только что понял, что мой 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);
    }

}

Это говорит мне, что он инициализирует сервлет, который, как я предполагал, undertow основан на зависимостях, но был ли я неправ?

1 Ответ

0 голосов
/ 09 марта 2019

Вам нужно исключить кота из сборки:

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'
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...