Spring
Kiss_in_the_Rain
邮箱:[email protected]
QQ:632201156
展开
-
eclipse安装Spring插件
第一步:第二步:第三步:第四步:选择接受、按照提示重启eclipse第五步:检查是否安装成功原创 2015-06-28 15:01:15 · 327 阅读 · 0 评论 -
Spring的HelloWorld
我使用的是spring-framework-4.0.0.RELEASE:1.必需jar包2.获得Spring容器ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");注意,这行代码会做如下几件事情:1.实例化Spring容器2.调原创 2015-06-28 15:55:24 · 231 阅读 · 0 评论 -
Spring属性注入
1.根据属性的set方法注入①.Bean对象的属性必须要有对应的set方法,get方法可以没有2.构造器注入①.以下两种方式是等效的,可以指定是构造器的第几个参数②.构造器匹配问题public Car(String brand, double maxSpeed ,String location) {原创 2015-06-28 17:12:24 · 255 阅读 · 0 评论 -
Spring注入集合属性
1.使用list注入集合属性public class Person {private String name;private int age;private List cars;}原创 2015-08-13 21:54:27 · 396 阅读 · 0 评论 -
P命名空间给Bean属性注值
1.使用P命名空间给Bean属性注值,前提需要引入P命名空间 Spring2.5以后才会有public class Person {private String name;private int age;private List cars;}原创 2015-08-13 22:40:17 · 371 阅读 · 0 评论 -
Spring自动装配Bean属性
public class Person {private String name;private Address address;private Car car;public Person() {}public String getName() {return name;}public void setName(String原创 2015-08-15 17:30:38 · 324 阅读 · 0 评论 -
Spring继承Bean的配置
1.使用parent配置继承bean//address2继承了address1,继承了其city属性的值,继承了其类类型的配置ApplicationContext ac = new ClassPathXmlApplicationContext("applicationContext.xml");Address address1 = (Address) ac.getB原创 2015-08-15 18:10:10 · 292 阅读 · 0 评论