package com.soft.service;
public class HelloService {
public HelloService() {
System.out.println("初始化HelloService");
}
public void helloService(){
System.out.println("hello world ! ! !");
}
}
第四步:创建一个测试类
package com.soft.service;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class HelloServiceTest {
public static void main(String[] args) {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring-config.xml");
HelloService helloService = (HelloService) context.getBean("helloService");
helloService.helloService();
}
}