Spring 基础
Posted 【唐】三三
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Spring 基础相关的知识,希望对你有一定的参考价值。
Helloworld.class
public class Helloworld {
private String name;
public void setName(String name) {
System.out.println("setName:"+name);
this.name = name;
}
public void hello(){
System.out.println("hello:"+name);
}
}
输出
public static void main(String[] args) {
// Helloworld helloworld = new Helloworld();
// helloworld.setName("tangsan");
// helloworld.hello();
//1.创建Spring的IOC容器对象
ApplicationContext context =
new ClassPathXmlApplicationContext("applicationContext.xml");
//2.从IOC获取 Bean 实例
Helloworld hello = (Helloworld)context.getBean("helloWorld");
hello.hello();
}
以上是关于Spring 基础的主要内容,如果未能解决你的问题,请参考以下文章