在我的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
}
}