问题
I'm developing a reactive project using Spring Boot 2 and reactive starters. My problem is that when I start the app, the Tomcat server it's started instead of Netty.
Here is my dependencies task from build.gradle file:
dependencies {
compile("org.springframework.boot:spring-boot-starter-actuator:${springBootVersion}")
compile("org.springframework.boot:spring-boot-starter-webflux:${springBootVersion}")
compile("org.springframework.boot:spring-boot-starter-hateoas:${springBootVersion}")
compile group: 'com.github.tomakehurst', name: 'wiremock', version: '2.15.0'
compile("ro.orange.omoney:lms-token-client:0.1.0-SNAPSHOT")
testCompile("org.springframework.boot:spring-boot-starter-test:${springBootVersion}")
}
Can you tell me why I face this problem? Thank you!
回答1:
Your project depends on spring-boot-starter-hateoas
, which depends on spring-boot-starter-web
, which depends on spring-boot-starter-tomcat
. The final dependency causes that Tomcat is configured to run the application.
In general, you would have to exclude spring-boot-starter-web
explicitely to bypass Tomcat auto-configuration.
Though, in this particular case, I believe it won't help as spring-boot-starter-hateoas
project doesn't support web on reactive stack yet (in Spring Boot 2.0.0.RELEASE).
It seems that it's either HATEOAS or reactive web at the moment.
See HATEOAS on Spring Flux/Mono response for more details.
来源:https://stackoverflow.com/questions/49607828/netty-server-isnt-used-in-spring-boot-2-with-reactive-starter