添加
后<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka</artifactId>
</dependency>
到我的依赖项我得到以下异常
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [example.nagios.notificationmanager.core.nagiosapi.NagiosAPIService]: Illegal arguments for constructor; nested exception is java.lang.IllegalArgumentException: argument type mismatch
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:158)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:122)
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:267)
... 24 more
Caused by: java.lang.IllegalArgumentException: argument type mismatch
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:147)
... 26 more
因此无法使用以下构造函数
创建服务@Autowired
public NagiosAPIService(@Value("${nagios.state.uri}") String nagiosStateUri,
@Qualifier("systemAuthorized") RestTemplate restTemplate, NagiosCheckService nagiosCheckService) {
this.nagiosStateUri = nagiosStateUri;
this.restTemplate = restTemplate;
this.nagiosCheckService = nagiosCheckService;
}
我在另一个之后移除了一个参数,它是导致错误的RestTemplate。
在我的依赖项中没有spring-cloud-starter-eureka,一切正常。 有谁可以告诉我为什么尤里卡会导致这个错误?
答案 0 :(得分:4)
我认为只是存在一些(可选,但默认情况下,如果您使用该启动器处于活动状态)自动配置来监控指标的休息模板使用情况。您仍然可以自动装配RestOperations
,或设置spring.aop.proxy-target-class=true
以使其按原样运行。