首页 > 解决方案 > org.springframework.beans.factory.BeanCreationException on Spring Boot 从 1.5 版升级到 2.1 版

问题描述

在我的 Spring Boot 应用程序中,将 Spring Boot 从 1.5 升级到 2.1 版本时出现错误:

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'pushNotificationsController': Unsatisfied dependency expressed through field 'pushNotificationUtil'; 

nested exception is 

org.springframework.beans.factory.UnsatisfiedDependencyException: 

Error creating bean with name 'pushNotificationsUtil': Unsatisfied dependency expressed through field 'pushNotificationFeignClient'; 

nested exception is 

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.xyz.abd.service.PushNotificationFeignClient': FactoryBean threw exception on object creation; 

nested exception is java.lang.UnsupportedOperationException
    at 
org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:596)
    at 

org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:90)

我在下面分享源代码:

@SpringBootApplication
@EnableDiscoveryClient
EnableCircuitBreaker
@ServletComponentScan
@EnableCaching
@ComponentScan({"com.abc.upoint","com.def.portal"})
@EnableFeignClients
public class Application {

    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }
}

PushNotificationsController.java:

@RestController
public class PushNotificationsController {

  @Autowired
  private PushNotificationsUtil pushNotificationUtil;
}

PushNotificationsUtil.java:

@Component
public class PushNotificationsUtil {

    @Autowired
    private PushNotificationFeignClient pushNotificationFeignClient;
}

PushNotificationFeignClient.java:

import org.springframework.cloud.openfeign.FeignClient;

@FeignClient(name="channel-pushnotifications", url = "${onesignal.url:#{''}}", fallback = 
PushNotificationFeignClient.PushNotificationFallback.class
                                      , configuration=UpointFeignProxyConfiguration.class)
public interface PushNotificationFeignClient {

    class PushNotificationFallback implements PushNotificationFeignClient {
       // Method Implementations
    }

}

标签: spring-boot

解决方案


推荐阅读