spring-cloud / spring-cloud-openfeign

Support for using OpenFeign in Spring Cloud apps
Apache License 2.0
1.21k stars 785 forks source link

feignclient does not work properly under springboot3.0 #795

Closed admintertar closed 1 year ago

admintertar commented 1 year ago

Describe the bug

. _ _ /\ / '_ () \ \ \ \ ( ( )\ | ' | '| | ' \/ ` | \ \ \ \ \/ _)| |)| | | | | || (| | ) ) ) ) ' |__| .|| ||| |\, | / / / / =========|_|==============|__/=//// :: Spring Boot :: (v3.0.0)

2022-12-01T16:01:39.816+08:00 INFO 15273 --- [ restartedMain] com.waitylyou.demo.DemoApplication : Starting DemoApplication using Java 17.0.5 with PID 15273 (/Users/ping/work-space/com.waitylyou/demo/target/classes started by ping in /Users/ping/work-space/com.waitylyou/demo) 2022-12-01T16:01:39.820+08:00 INFO 15273 --- [ restartedMain] com.waitylyou.demo.DemoApplication : No active profile set, falling back to 1 default profile: "default" 2022-12-01T16:01:39.868+08:00 INFO 15273 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable 2022-12-01T16:01:39.868+08:00 INFO 15273 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG' 2022-12-01T16:01:40.943+08:00 INFO 15273 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 31112 (http) 2022-12-01T16:01:40.953+08:00 INFO 15273 --- [ restartedMain] o.apache.catalina.core.StandardService : Starting service [Tomcat] 2022-12-01T16:01:40.954+08:00 INFO 15273 --- [ restartedMain] o.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/10.1.1] 2022-12-01T16:01:41.024+08:00 INFO 15273 --- [ restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext 2022-12-01T16:01:41.025+08:00 INFO 15273 --- [ restartedMain] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1156 ms 2022-12-01T16:01:41.079+08:00 WARN 15273 --- [ restartedMain] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'testController' defined in file [/Users/ping/work-space/com.waitylyou/demo/target/classes/com/waitylyou/demo/TestController.class]: Unsatisfied dependency expressed through constructor parameter 0: Error creating bean with name 'com.waitylyou.demo.feign.TestFeign': Unexpected exception during bean creation 2022-12-01T16:01:41.081+08:00 INFO 15273 --- [ restartedMain] o.apache.catalina.core.StandardService : Stopping service [Tomcat] 2022-12-01T16:01:41.095+08:00 INFO 15273 --- [ restartedMain] .s.b.a.l.ConditionEvaluationReportLogger :

Error starting ApplicationContext. To display the condition evaluation report re-run your application with 'debug' enabled. 2022-12-01T16:01:41.120+08:00 ERROR 15273 --- [ restartedMain] o.s.b.d.LoggingFailureAnalysisReporter :


APPLICATION FAILED TO START


Description:

Parameter 0 of constructor in com.waitylyou.demo.TestController required a bean of type 'org.springframework.cloud.openfeign.FeignContext' that could not be found.

Action:

Consider defining a bean of type 'org.springframework.cloud.openfeign.FeignContext' in your configuration.

Sample image

maxl2287 commented 1 year ago

I am having the same issue currently on my side...

01-12-2022 23:45:55.752 [main] ERROR o.s.b.d.LoggingFailureAnalysisReporter.report - ***************************APPLICATION FAILED TO START***************************Description:Parameter 0 of constructor in com.SomeService required a bean of type 'org.springframework.cloud.openfeign.FeignContext' that could not be found.Action:Consider defining a bean of type 'org.springframework.cloud.openfeign.FeignContext' in your configuration.

Only possible workaround is the importing of the AutoConfigurations:


@Generated
@EnableFeignClients
@SpringBootApplication
@ImportAutoConfiguration({FeignAutoConfiguration.class, HttpClientConfiguration.class})
public class MainApp{

  public static void main(String[] args) {
    SpringApplication.run(MainApp.class, args);
  }
}
admintertar commented 1 year ago

@maxl2287 Update the version of spring-cloud-dependencies to 2022.0.0-RC2

admintertar commented 1 year ago

need to add

spring-milestones Spring Milestones https://repo.spring.io/milestone false