1. What is Spring?
Spring is an open source framework.
Spring was born to simplify enterprise-level application development. Using Spring, you can implement simple JavaBeans that were previously only possible with EJB. function.
Spring is an IOC (DI) and AOP container framework.
2. Detailed description of Spring
Lightweight: Spring is non-intrusive - objects in applications developed based on Spring can not rely on Spring's API
Dependency injection: (DI-Dependency injection, IOC)
Aspect-oriented programming: (AOP-aspect oriented programming)
Container: Spring is a container because it contains and manages the life cycle of application objects
Framework: Spring implements the use of simple component configurations to form a complex application. In Spring, XML and java annotations can be used to combine these objects.
One-stop: based on IOC and AOP It can integrate open source frameworks and excellent third-party class libraries for various enterprise applications (in fact, Spring itself also provides Spring MVC for the presentation layer and Spring JDBC for the persistence layer)
3. Build a Spring environment
1. Install Spring Tool Suite by eclipse
SPRING TOOL SUITE is an Eclipse plug-in, which can be used to more conveniently develop Spring-based applications on the Eclipse platform.
2. Add packages
Add the following jar packages to the classpath of the project:
3. Spring configuration file: a A typical Spring project requires the creation of one or more bean configuration files, which are used to configure beans in the Spring IOC container. Bean configuration files can be placed in the classpath or in other directories.
4. Create a Spring project and write HelloWorld:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
|
5. Test results
The above is the entire content of this article. I hope that the content of this article can bring some help to everyone's study or work. I also hope to support the PHP Chinese website!
For more articles related to Java Spring quick start, please pay attention to the PHP Chinese website!