Spring boot 从1.5版到2.1版的Spring引导升级中的org.springframework.beans.factory.BeanCreationException
在我的Spring Boot应用程序中,将Spring Boot从1.5版升级到2.1版时出现错误:Spring boot 从1.5版到2.1版的Spring引导升级中的org.springframework.beans.factory.BeanCreationException,spring-boot,Spring Boot,在我的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';
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启动应用程序还是SpringMVC或SpringCore?请提供有关如何初始化应用程序上下文的详细信息。是的,这是一个Spring启动应用程序。请共享入口点类,可能还有整个
PushNotificationsUtil
类。是否有必要将PushNotificationFallback声明为内部类?我不知道这是否是问题的原因,但它可能会导致一些问题。我会尝试在“PushNotificationFeignClient”之外声明PushNotificationFallback
。