无法在运行于Tomcat上的基于Spring引导的Web应用程序中使用Spring的反应性WebClient。由于未解决的依赖关系,应用程序启动本身正在失败。
我查看了https://github.com/spring-projects/spring-boot/issues/9690,但不幸的是,这对我来说不是一个选项,因为我不能将WebApplication类型设置为None
我的分级档案:
dependencies {
compile(group: 'org.springframework.boot', name: 'spring-boot-starter-data-jpa') {
exclude(module: 'tomcat-juli')
}
compile group: 'org.springframework.boot', name: 'spring-boot-starter-data-redis'
compile group: 'org.springframework.boot', name: 'spring-boot-starter-web'
compile group: 'org.springframework.session', name: 'spring-session'
compile group: 'org.hibernate', name: 'hibernate-java8'
compile group: 'org.hibernate', name: 'hibernate-validator', version: '5.2.4.Final'
compile group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-guava'
compile group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-hibernate5'
compile group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-jsr310'
compile group: 'com.google.guava', name: 'guava'
compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.3.2'
compile group: 'org.postgresql', name: 'postgresql'
compile group: 'io.jsonwebtoken', name: 'jjwt', version:'0.9.0'
compile group: 'com.nimbusds', name: 'nimbus-jose-jwt', version:'5.12'
// Spring managed dependency is not working, so resorted to using specific version
// compile('org.springframework.boot:spring-boot-starter-webflux')
compile group: 'org.springframework.boot', name: 'spring-boot-starter-webflux', version: '2.1.4.RELEASE'
/*
compile group: 'org.springframework', name: 'spring-web-reactive', version: '5.0.0.M1'
compile group: 'org.springframework', name: 'spring-web', version: '5.1.6.RELEASE'
*/
implementation 'com.auth0:jwks-rsa:0.7.0
}
bootRepackage {
enabled = false
}错误:
Caused by: java.lang.NoClassDefFoundError: org/springframework/http/client/reactive/ClientHttpConnector
at org.springframework.web.reactive.function.client.WebClient.create(WebClient.java:144)然后我试着添加,
compile group: 'org.springframework', name: 'spring-web-reactive', version: '5.0.0.M1'然后抱怨别的事情,让我补充说
compile group: 'org.springframework', name: 'spring-web', version: '5.1.6.RELEASE'但是,在启动应用程序时出现了另一个错误,这使我认为还有其他问题。
准确地说,我只是想使用来自另一个MicroService (基于)的反应性WebClient调用一个MicroService。
使用RestTemplate可以很好地工作,但是我只想尝试一下反应式的WebClient,并坚持错误。
由于我们托管依赖项的方式,托管依赖项无法工作。我们的依赖服务器无法解决这些问题。这就是拥有特定版本的spring引导依赖项的原因
发布于 2019-04-26 01:35:17
org.springframework.http.client.reactive.ClientHttpConnector是spring-web jar的一部分,所以如果使用spring-boot-starter-webflux或spring-boot-starter-web,它应该是可用的。如果您正在编写基于servlet的传统应用程序,那么您应该使用spring-boot-starter-web。
检查gradle dependencies的输出以确保您有一个spring-web jar。如果你这么做了,很可能它已经被破坏了,你应该清除你的梯度缓存。
我还建议您使用Spring的托管依赖,而不是对每个依赖项指定版本号。这将确保您获得已知的协同工作的版本。
https://stackoverflow.com/questions/55856985
复制相似问题