标签:wired autowired single res 方法 system void 依赖 code
Spring中bean标签的属性和值:
<bean name="user" class="com.pojo.User" init-method="intMethod" destroy-method="destoryMethod" lazy-init="false" scope="singleton"> <property name="name" value="张三"></property> <property name="address" value="上海"></property> <property name="age" value="25"></property> <property name="car" ref="car"></property> </bean> <bean name="car" class="com.pojo.Car"> <property name="brand" value="大众"></property> <property name="price" value="12"></property> </bean>
public class User { @Autowired private String name; private String address; private int age; public User() { System.out.println("User无参构造方法..."); } public void intMethod() { System.out.println("User初始化....."); } public void destoryMethod() { System.out.println("User销毁....."); } }
标签:wired autowired single res 方法 system void 依赖 code
原文地址:https://www.cnblogs.com/whx20100101/p/9807252.html