<? Xml version = "1.0" encoding = "UTF-8"?>
<Beans xmlns = "http://www.springframework.org/schema/beans"
Xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance"
Xmlns: context = "http://www.springframework.org/schema/context"
Xsi: schemaLocation = "http://www.springframework.org/schema/beans
Http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
Http://www.springframework.org/schema/context
Http://www.springframework.org/schema/context/spring-context-3.0.xsd>
<Context: annotation-config/>
<Bean name = "u" class = "dao. impl. UserDaoImpl"> </bean>
<Bean id = "userService" class = "service. UserService">
</Bean>
</Beans>
Seter method annotation in service package
@ Autowired
Public void setUserDao (UserDao userDao ){
This. userDao = userDao;
}
Note: The sequence of context packages referenced in beans cannot be changed. Otherwise, an exception org. springframework. beans. factory. xml. xmlBeanDefinitionStoreException: Line 4 in XML document from class path resource [applicationContext. xml] is invalid; nested exception is org. xml. sax. SAXParseException: cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'Context: annotation-config '.
Source: http://blog.163.com/kxf_327/blog/static/1954850782011822112424676/