嵌套异常无法自动连线字段

时间:2019-07-02 06:25:16

标签: java maven spring-boot

在执行时,将引发此错误。我正确地配置了实现类和bean。不确定为什么会显示启动错误。

  

org.springframework.beans.factory.BeanCreationException:错误   创建名称为“ App1ServiceProvider”的bean:注入自动装配   依赖失败;嵌套异常为   org.springframework.beans.factory.BeanCreationException:无法   自动连线栏位:私人   com.apps.app1.web.rest.services.commons.App1ServicesBase   com.apps.app1.web.rest.services.commons.App1ServiceProvider.app1ServicesBase;   嵌套异常为   org.springframework.beans.factory.NoUniqueBeanDefinitionException:否   类型的合格豆   定义[com.apps.app1.web.rest.services.commons.App1ServicesBase]:   预期的单个匹配bean,但发现3:   App1RestAuth,App1RestService,App1ServicesBase

实现App1ServiceProvider类:

@Service
public class App1ServiceProvider extends ServiceProviderBase {

@Autowired
private App1RestAuth app1RestAuth;

@Autowired
private App1ServicesBase app1ServicesBase;

@Autowired
private App1RestService app1RestService;


public App1RestAuth getApp1RestAuth() {
    return app1RestAuth;
}

public App1ServicesBase getApp1ServicesBase() {
    return app1ServicesBase;
}

public App1RestService getApp1RestService()  {
    return app1RestService;
}
}

Spring配置:

<bean id="App1RestAuth" class="com.apps.app1.web.rest.services.App1RestAuth"/>
<bean id="App1RestService" class="com.apps.app1.web.rest.services.App1RestService"/>
<bean id="App1ServiceProvider" class="com.apps.app1.web.rest.services.commons.App1ServiceProvider"/>
<bean id="App1ServicesBase" class="com.apps.app1.web.rest.services.commons.App1ServicesBase"/>

实现App1ServiceProvider类:

@Service
public class App1ServiceProvider extends ServiceProviderBase {

@Autowired
private App1RestAuth app1RestAuth;

@Autowired
private App1ServicesBase app1ServicesBase;

@Autowired
private App1RestService app1RestService;


public App1RestAuth getApp1RestAuth() {
    return app1RestAuth;
}

public App1ServicesBase getApp1ServicesBase() {
    return app1ServicesBase;
}

public App1RestService getApp1RestService()  {
    return app1RestService;
}
}

Spring配置:

<bean id="App1RestAuth" class="com.apps.app1.web.rest.services.App1RestAuth"/>
<bean id="App1RestService" class="com.apps.app1.web.rest.services.App1RestService"/>
<bean id="App1ServiceProvider" class="com.apps.app1.web.rest.services.commons.App1ServiceProvider"/>
<bean id="App1ServicesBase" class="com.apps.app1.web.rest.services.commons.App1ServicesBase"/>

0 个答案:

没有答案