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();
    }原文:https://www.cnblogs.com/tangge/p/9471911.html