What is Spring

来源:互联网 发布:sql查重复记录 编辑:程序博客网 时间:2024/06/01 17:40
    Spring is a framework that help software developers to build a better enterprise.It has two primary features which are dependency injection(DI) and aspect-oriented programming.In a word,at the root of almost everything Spring provides are a few  foundational ideas,all foucused on Spring's fundamental mission:Spring simplifies Java development.
   For example,When I want to eat an apple.What should I do?I think I should go to the supermarket(what I means was that I have the responsibility to care about what I really need,where I should to find them.Oh my god,there are so many things to do).So the grogram is just like this:
   
public class Person{
      Food favoriteFood;
       public Person(){
            favoriteFood =new Apple();
      }
      public void eat(){
             System.out.println(favoriteFood.name);
      }
}OK,Now I can eat my favorite Food.But there is a problem.One day I find I don't like apple any more,maybe I like  Banana.So what should I do?Change my program?I can't belive that I only want to eat Banana,you tell my to change my program?
    Why can't our program be flexible、maintainable,Scalable?Because We use the key word "new",this word tell our program there is no change forever,just use it.But how to simplify Java development?
     To beck up its attack on Java complexity,Spring employs four key strategies:
     1、Lightweight and minimally invasive development with POJOs.
     2、Loose coupling through DI and interface orientation.
     3、Declarative programming through aspects and common conventions.
     4、Eliminating boilerplate code with aspects and templates.

1 0