There are several such errors encountered when using WEBX development, summarize.
Add the configuration of the timer task to the Applicationcontext.xml:
<bean name= "Applicationservice" class= "Com.taobao.scm.tenv.monitor.service.impl.ApplicationServiceImpl"/> <bean name= "Productservice" class= "Com.taobao.scm.tenv.monitor.service.impl.ProductServiceImpl"/> <bean name= "Buservice" class= "Com.taobao.scm.tenv.monitor.service.impl.BuServiceImpl"/> <bean Name= "Unitservice" class= "Com.taobao.scm.tenv.service.impl.UnitServiceImpl"/>
The last line, add a unitservice bean.thisBeanis an existingServiceimplementation class.
@Servicepublic class Unitserviceimpl implements Unitservice {@ResourceUnitDAO unitdao;public list<unitdo> Findunitbycondition (Unitdo unitdo) {return unitdao.findlistbyexample (UNITDO);}}
as shown above, I'm using annotations here. @Service , Spring This class is loaded automatically. Compile, the result is reported as follows error:
2015-06-08 17:22:03.777:warn::failed Startup of the context [email Protected]{/,src/main/webapp} Org.springframework.beans.factory.BeanCreationException:
Error creating Bean with Name ' module.screen.MachineApply ':
Injection of resource dependencies failed; Nested exception is
Org.springframework.beans.factory.NoSuchBeanDefinitionException:
No unique bean of type [Com.taobao.scm.tenv.service.interfaces.UnitService]
is defined:expected single matching beans but found 2: [Unitserviceimpl, Unitservice]
Based on the error message to the Module.screen.MachineApply file, the following definition was found:
public class Machineapply { @Resource userservice userservice; @Resource machineservice Machineservice; @Resource mirrorservice Mirrorservice; @Resource specificationservice Specificationservice; @Resource Unitservice Unitservice;
The last line, @Resource a unitserver unitservice. The problem is the name here,whenSpringInitializeBeanwill monitor the initialization of theBeanwhether the same name already existsBean,applicationcontext.xml inside the name is Unitservice, and Machineapply.java inside is unitservice, so this bean was loaded 2 times, causing conflict. The solution is:
1, the Machineapply.java inside is Unitservice changed into a canonical type of unitservice. Recommended
2, change the unitservice inside the applicationcontext.xml into Unitservice. (not recommended, if the Java file in other places also useful to this, should be unified change, so the canonical name is very important)
This naming of the nonstandard stepped on a big hole, but also for the bean loading process has a little understanding. Combined with online analysis, the following are summarized below:
1. @Service when declaring a bean, if you do not specify a name, it defaults to a lowercase letter in the class name.
2. When spring initializes the bean, it monitors whether the bean to be initialized already has a bean of the same name.
3. The order of spring initialization beans depends on the order in which you configure the XML.
4.spring only maintains name consistency when the bean is initialized.
Attach an analysis of another document: http://mixer-b.iteye.com/blog/1563851
No Unique Bean of type