Spring is a very good lightweight framework, and through spring's IOC container, our focus is on the business logic that needs to be implemented. Support for AOP enables us to dynamically enhance the business approach. Writing a common business logic bean is easy and easy to test because it can separate unit tests from the Java container, such as the servlet,jsp environment. The final step is to organize these business beans in the Spring framework as XML configuration files, and they work as we intended! Very easy!
This article presents a basic spring Getting started example and demonstrates how to use spring's AOP to separate complex business logic into every aspect.
1. Development environment Configuration
2. Writing the Bean interface and its implementation
3. Configure the Bean in spring and get an instance of the bean
4. Write advisor to enhance Servicebean
5. Summarize
1. Development environment Configuration
First, the Java environment needs to be configured correctly. Recommended installation of JDK1.4.2 and proper configuration of environment variables:
JAVA_HOME=<JDK installation directory >
Classpath=.
Path=%java_home%\bin .....
We will use the free Eclipse 3.1 as the IDE. Create a new Java Project, copy the Spring release package Spring.jar and Commons-logging-1.0.4.jar to the project directory, and configure Java in Project > properties Build Path: