<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE beans PUBLIC "-//SPRING/DTD BEAN/EN" "http://www.springframework.org/dtd/spring-beans.dtd"><beans>
<bean id = "user" class="com.sky.spring.study03.User" scope = "prototype">
<property name = "id" value = "1"></property>
<property name = "name" value = "张三"></property>
<property name = "age" value = "19"></property></bean></beans>
发现scope报红
Attribute "scope" must be declared for element type "bean"
经过查阅发现是因为 该语法需要在bean2.0的环境下编写 将代码改为
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE beans PUBLIC "-//SPRING/DTD BEAN 2.0/EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd"><beans>
<bean id = "user" class="com.sky.spring.study03.User" scope = "prototype">
<property name = "id" value = "1"></property>
<property name = "name" value = "李四"></property>
<property name = "age" value = "19"></property></bean></beans>