A, Spring Core Concepts
1, the reverse control (IoC) and dependency injection (DI)
concept
IoC: A creation and management of external technical term component depends.
For example: To manufacture a pen Wang, Wang made themselves previously required, Ioc this work is to let third Fang Xiaoming (container: such as factories) to produce and manage.
DI: A method of operating when an object (including attributes) through the container, to another object of art. IoC relation to DI corresponding to sides of a coin, so that they are integral relationship on both sides, in the context of Spring, these terms are interchangeable concepts, without any loss
of illustration: by a third Fang Xiaoming Wang ( containers: the plant) for producing a pencil (object), and then to use when Ronaldinho, via the third Fang Xiaoming transferred to Ronaldinho, rather than directly to Wang Ronaldinho.
Advantages and disadvantages of using IoC / DI's
Advantage
- Reducing adhesion (code reuse)
- Simplify the application configuration (change from mysql to oracle database, simply suitably arranged business object dependency)
- Dependencies can be managed in a single common storage (the dependency centralized management, so that the management simpler and less error)
- Improve testability (test requires only simple business code, and the test can be layered (DAO layer, service layer, domain layer, Controller layer), make testing easier definition)
- Develop good application design (reducing the workload, focus on your business, not the frame, and more use of the interface in order to achieve the decoupling effect)
Shortcoming
- For people not familiar with the code of speaking, DI / IoC hard for them to know which achieve the objects of a particular dependency that connection.
2, additional features of the Spring 5
- Support Java 9
- Spring implemented using Aspect Oriented Programming (AOP: Aspect Oriented Programming)
- Support for AspectJ pointcut expression style
- Support @AspectJ comment (Spring 3.2 start)
- DI implementation supports aspects in AspectJ
- A weaving when supporting Spring judge by reason of loading cationContext
- Spring Expression Language
- From Spring 3.0, Spring introduced the expression language SpEL (Spring Exprssion Language),
- Is a standard expression language, other alternative expression language EL (Expression Language), to make a unified expression language UEL (Unified Expression Language).
- Spring validation Validation, starting Spring 4.0, JSR-349 (Bean Validation) supported version 1.1
- In the Spring data access: The JDBC API has been simplified package of (Sql and NoSql database access, the proposed research Spring Data projects)
- Spring objects / XML mapping (conversion JavaBean and XML)
- Management (programmatic and declarative transaction control)
- Simplify and integration with JEE
- MVC Web layer (Spring WebFlux and Spring MVC)
- WebSocket support (for defined between a client and a server through a persistent connection member API)
- Remote support (RMI, JAX-WS, JMS, AMQP, REST, etc.)
- Mail Support
- Job scheduling support
- Dynamic scripting support (Groovy, Jruby and BeanShell)
- Simplifies exception handling ( non checked exception unchecked exceptions: RuntimeException and its subclasses, and error (Error) )
Two, Spring project and alternatives
1, Spring projects
- Spring Tool Suite (Spring IDE and Spring Tool Suite (STS) tool )
- Spring Security (offers comprehensive support for web applications and method-level security)
- Spring Boot (simplified create work items)
- Spring Batch and Integration (Spring Batch and Spring Integration)
- Other (Spring XD, Android for Spring, Spring Mobile, Spring Social and Spring AMQP, more message information )
2, Spring alternatives
- JBoss Seam framework (Spring and the main difference is entirely based on JBoss JEE standard development)
- Google Guice
- PicoContainer
- JEE 7 container
Reproduced in: https: //www.jianshu.com/p/26dd03e17d44