org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'personalCenterController': Injection of autowired dependencies failed; nested exception is
org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.tianjian.property.service.WorkOrderService
com.tianjian.property.wechat.controller.PersonalCenterController.workorderService; nested exception is org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type
[com.tianjian.property.service.WorkOrderService] is defined: expected single matching bean but found 2: workOrderService,orderService
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1210)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:755)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:434)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4729)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5167)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:586)
at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1750)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.tianjian.property.service.WorkOrderService
com.tianjian.property.wechat.controller.PersonalCenterController.workorderService; nested exception is org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type
[com.tianjian.property.service.WorkOrderService] is defined: expected single matching bean but found 2: workOrderService,orderService
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:561)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331)
... 26 more
Caused by: org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type [com.tianjian.property.service.WorkOrderService] is defined: expected single matching bean
but found 2: workOrderService,orderService
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1054)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:942)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:533)
... 28 more
具体代码:
@RequestMapping("/personal-center")
@Controller
public class PersonalCenterController {
private static final String WORKORDER_CONFIRM_NONE_FINISH = "0";
@Value("${wx.notify.host}")
private String hostName;
@Autowired
private PersonalCenterService personalCenterService;
@Autowired
private WorkOrderService workorderService;//这个workorderService需要改成workOrderService
@Autowired
EnterpriseUsersService enterpriseUsersService;
@Autowired
private FeeDao feeDao;
@Autowired
BookingService bookingService;
@Autowired
ComplainService complainService;
@Autowired
WxConfigService wxConfigService;
@Autowired
ComplaintsTypeService complaintsTypeService;
@Autowired
UserService userService;
@Autowired
CommentService commentService;
@Autowired
private AdService adService;
@Autowired
private PointsGradeService pointsGradeService;
@Autowired
private PropertyService propertyService;
...............................................................................................................
//居家公共取消
@RequestMapping("/service/cancel-order/{id}/{remark}/{status}")
@ResponseBody
public boolean cancelOrder(@PathVariable Integer id,String remark,String status) {
return this.workorderService.cancelOrder(id,remark,status);
}
这会报注解继承冲突。解决办法就是把注解那改下:
@Autowired
private WorkOrderService workorderService;
改为:
@Autowired
private WorkOrderService workOrderService;