bean6.xml 1016 B

123456789101112131415161718192021
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <beans xmlns="http://www.springframework.org/schema/beans"
  3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  4. xmlns:context="http://www.springframework.org/schema/context"
  5. xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd">
  6. <!-- 扫描的包-->
  7. <context:component-scan base-package="com"></context:component-scan>
  8. <!--实例化user-->
  9. <bean id="user1" class="com.sf.entity.User">
  10. <property name="userId" value="1001"></property>
  11. <property name="userName" value="admin"></property>
  12. <property name="age" value="18"></property>
  13. </bean>
  14. <!-- 实例化student-->
  15. <bean id="student" parent="user1" class="com.sf.entity.Student" scope="prototype">
  16. <property name="gender" value="男"></property>
  17. </bean>
  18. </beans>