spring-cloud / spring-cloud-commons

Common classes used in different Spring Cloud implementations
Apache License 2.0
706 stars 705 forks source link

Spring boot 3.0 fail with jersey and spring cloud (open feign, ect) #1217

Closed Fyro-Ing closed 1 year ago

Fyro-Ing commented 1 year ago

When using Spring boot 3.0 with jersey (not mvc) with spring cloud open feign, start failed

org.springframework.beans.factory.BeanDefinitionStoreException: Failed to process import candidates for configuration class [com.fortuneo.api.esign.Application]: class path resource [org/springframework/web/servlet/config/annotation/WebMvcConfigurer.class] cannot be opened because it does not exist
    at org.springframework.context.annotation.ConfigurationClassParser.processImports(ConfigurationClassParser.java:524)
    at org.springframework.context.annotation.ConfigurationClassParser$DeferredImportSelectorGroupingHandler.lambda$processGroupImports$1(ConfigurationClassParser.java:726)
    at java.base/java.lang.Iterable.forEach(Iterable.java:75)
    at ...
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:732)
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:434)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:310)
    at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:150)
    at com.fortuneo.api.esign.Application.main(Application.java:18)
Caused by: java.io.FileNotFoundException: class path resource [org/springframework/web/servlet/config/annotation/WebMvcConfigurer.class] cannot be opened because it does not exist
    at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:211)
    at org.springframework.core.type.classreading.SimpleMetadataReader.getClassReader(SimpleMetadataReader.java:54)
    at org.springframework.core.type.classreading.SimpleMetadataReader.<init>(SimpleMetadataReader.java:48)
    at ...

Spring cloud open feign include org.springframework.cloud:spring-cloud-commons with a default config for web mvc

https://github.com/spring-cloud/spring-cloud-commons/blob/8ec45e03b00f3ad96bbc03a86390ed029364bb89/spring-cloud-commons/src/main/java/org/springframework/cloud/commons/security/ResourceServerTokenRelayAutoConfiguration.java#L58

To reproduce : run starter

https://start.spring.io/#!type=gradle-project&language=java&platformVersion=3.0.4&packaging=jar&jvmVersion=17&groupId=com.example&artifactId=demo&name=demo&description=Demo%20project%20for%20Spring%20Boot&packageName=com.example.demo&dependencies=lombok,cloud-feign,jersey

Workaround : set "spring.cloud.mvc.token-relay.enabled" at false

OlgaMaciaszek commented 1 year ago

Issue moved to spring-cloud/spring-cloud-openfeign spring-cloud/spring-cloud-commons#1295 via Zenhub