eclipse-->Windows-->Preferences-->XML Catalog
Add
File System, 选择约束的文件路径, 比如spring-beans-4.2.xsd
打开,
Key type选Schema location, 复制Location中的文件名spring-beans-4.2.xsd, 在Key中的.../beans文件夹后面加"/"再粘贴以上复制的文件名. OK, 然后继续添加context, aop, tx的约束文件, 添加完后如下:
在maven dao项目中新建applicationContext-dao.xml spring配置文件
Next
Next-->Select XML Catalog entry-->http://www.springframework.org/schema/beans/spring-beans-4.2xsd(添加beans的约束)
Next-->Root element:-->beans -->Edit
删除P-->OK-->Finish(忽略prefix的提示)
含有基本约束的spring xml(还不够)
继续添加其他约束, 选择左下角Design
窗口空白处鼠标右击
Edit Namespaces...
Add-->Specify New Namespace
Browser...
Select XML Catalog entry找到http://www.springframework.org/shema/aop/spring-aop-4.2.xsd-->OK
Prefix:输入aop, NameSpace Names:将Location Hint中除去/spring-aop-4.2.xsd,其余路径粘贴过来.
OK, 然后用以上相同步骤继续添加context和tx的约束.
在添加context时,在Add Namespace Declarations窗口 的Prefix输入context,Location Hint输入去除"\"和xsd文件名的路径.
在添加tx时,在Add Namespace Declarations窗口 的Prefix输入tx,Location Hint输入去除"\"和xsd文件名的路径.
OK, 底部点击Source
经过整理代码(换行对齐) applicationContext-dao.xml
<?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:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.2.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.2.xsd ">
</beans>