spring
Spring最重要的部分是IoC Container,它的作用是配置和管理Java对象的生命周期。
反转控制和依赖注入
// Interface HelloWorld public interface HelloWorld { public void sayHello(); } // Class implements HelloWorld public class SpringHelloWorld implements HelloWorld { public void sayHello() { System.out.println("Spring say Hello!"); } } // Other class implements HelloWorld public class StrutsHelloWorld implements HelloWorld { public void sayHello() { System.out.println("Struts say Hello!"); } } // And Service class public class HelloWorldService { // Field type HelloWorld private HelloWorld helloWorld; // Constructor HelloWorldService // It initializes the values for the field 'helloWorld' public HelloWorldService() { this.helloWorld = new StrutsHelloWorld(); } }
参考网址:http://www.yiibai.com/spring/spring-tutorial-for-beginners.html#

浙公网安备 33010602011771号