spring的自动注解@Autowired配置

<?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”> <context:annotation-config />

<bean></bean> <bean> </bean>

</beans>

在service包中seter方法注解

@Autowiredpublic void setUserDao(UserDao userDao) {this.userDao = userDao;}

特别注意的地方:beans中引用的context包顺序不能改变,,否则会报异常org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line4 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’.

来源:

太过于近,彼此身上隐性的刺又会深深的伤害对方。

spring的自动注解@Autowired配置

相关文章:

你感兴趣的文章:

标签云: