util
P命名空间实际上是set注入的另一种写法(我也不知道为什么要开发这么多种写法???为了方便反而更乱了)
C命名空间实际上是构造器注入的另一种写法
UTIL实际上是工具类的另一种写法
三者都要改变头文件
首先是P命名空间
首先要引入可以写P命名空间的约束
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
</beans>
首先复制一行
xmlns="http://www.springframework.org/schema/beans"
然后改写为
xmlns:p="http://www.springframework.org/schema/p"
此时已经可以用p命名来
此时的语法是
<bean id="aaa" class="com.chenchen.dao.juese" p:name="学习" p:skill="大家"></bean>
当然也可引用p-ref注入别的引用类型
c命名空间就不记录了。
util命名空间如下
首先还是要引入
xmlns:util="http://www.springframework.org/schema/util"
然后在复制一行
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
将其中所有的beans改为util
即为
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd
整体是是这样的
<?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:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">
然后就可以在配置文件中写<util>标签
util主要是配置工具类 比如 连接数据库所需要的url useranme等