1、先下载环境 链接:http://spring.io/tools/sts/legacy
也可以手动增加插件,自行百度。
2、下载包
地址:http://download.csdn.net/detail/u010310183/9552632
3、代码区
package com.huoxin.bean;
public class HelloWorld {
private String name;
public void setName(String name) {
this.name = name;
}
public void hello(){
System.out.println("hello:"+name);
}
}
package com.huoxin.bean;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class Main {
public static void main(String[] args) {
System.out.println("ssssssss");
// HelloWorld helloworld = new HelloWorld();
// helloworld.setName("hfkjdshf");
ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
HelloWorld helloworld = (HelloWorld) ctx.getBean("helloworld");
helloworld.hello();
}
}
4、创建applicationContext.xml 配置bean
<!-- 配置bean -->
<bean id = "helloworld" class="com.huoxin.bean.HelloWorld">
<property name="name" value = "Spring"></property>
</bean>
简单demo完成。