spring使用注解时配置文件的配置

来源:互联网 发布:将字符串转换为json 编辑:程序博客网 时间:2024/04/30 07:31
<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.xsd      http://www.springframework.org/schema/context      http://www.springframework.org/schema/context/spring-context-4.0.xsd"><!-- 通过注解的方式 --><context:annotation-config/><bean id="personDaoBean" class="cn.axin.dao.impl.PersonDaoBeanImpl"/><bean id="personServiceBeanImpl" class="cn.axin.service.impl.PersonServiceBeanImpl"/></beans>


特别注意:http://www.springframework.org/schema/context

http://www.springframework.org/schema/context/spring-context-4.0.xsd

的位置顺序。否则xml文件的提示功能可能出现问题,还有可能出现无法成功运行的情况,报:

org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 1 in XML document from class path resource [beans.xml] is invalid; nested exception is org.xml.sax.SAXParseException: White spaces are required between publicId and systemId.

0 0
原创粉丝点击