¿Para qué me sirve y qué resuelvo con Spring?
Hola chavos, pues esta vez el motivo de mi post es para preguntarles ¿cuáles son los apectos que favorecen el uso de Spring, cuál es la magia de este framework ?
Estoy iniciando con Spring y me gustaria que con lenguaje coloquial alguien me ayude a entender más
Porque he visto definiciones como:
Java components / classes should be as independent as possible of other Java classes. This increases the possibility to reuse these classes and to test them independently of other classes(Unit Testing). To decouple Java components from other Java components the dependency to a certain other class should get injected into them rather that the class itself creates / finds this object.
A class A has a dependency to class B if class uses class B as a variable.
If dependency injection is used then the class B is given to class A via
the constructor of the class A - this is then called construction injection
a setter - this is then called setter injection
The general concept between dependency injection is called Inversion of Control. A class should not configure itself but should be configured from outside.
A design based on independent classes / components increases the re-usability and possibility to test the software. For example if a class A expects a Dao (Data Access object) for receiving the data from a database you can easily create another test object which mocks the database connection and inject this object into A to test A without having an actual database connection.
A software design based on dependency injection is possible with standard Java.
Spring just add some simplifications in using dependency injection by providing a standard way of providing the configuration and by managing the reference to the created objects.
The Spring Framework is a very comprehensive framework.
The fundamental functionality provided by the Spring Container is dependency injection. Spring provides a light-weight container, e.g. the Spring core container, for dependency injection (DI).
This container allows to inject required objects into other objects. This results in a design in which the Java class are not hard-coupled. The injection in Spring is either done via setter injection of via construction injection.
These classes which are managed by Spring must conform to the JavaBean standard.
In the context of Spring classes are also referred to as beans or as spring beans.
The Spring core container:
handles the configuration, generally based on annotations or on an XML file (XMLBeanFactory)
manages the selected Java classes via the BeanFactory
The core container uses the so-called bean factory to create new objects. New objects are generally created as Singletons if not specified differently.
Pero no me cae el 20, no me queda claro para que me sirve Spring que no se pueda hacer con alguna otra tecnologia(standard java,jsp,servlets,jsf,struts, etc)
He hecho los ejemplos que vienen en los tutoriales de Internet pero pues no me convence
Lo que si esta muy bien es Spring JDBC
De antemano gracias