Spring配置文件定义类时用id和name的区别

<?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-2.5.xsd">

  <bean name="user" class="com.zchen.dao.impl.UserDAOImpl">
  </bean>
	
  <bean id="userService" class="com.zchen.service.UserService">
  </bean>
  
</beans>

 其中:用id和name都是实例化一个bean对象不同的是用name可以用特殊字符。

猜你喜欢

转载自wwwzchen.iteye.com/blog/1069870