- Spring AOP - Home
- Spring AOP - Overview
- Spring AOP - Environment Setup
- Spring AOP - Core Concepts
- Spring AOP - Advice Types
- Spring AOP - Implementations
By XML Configuration Examples
- Spring AOP - Application
- Spring AOP - Pointcut Methods
- Spring AOP - Before Advice
- Spring AOP - After Advice
- Spring AOP - After Returning Advice
- Spring AOP - After Throwing Advice
- Spring AOP - Around Advice
By Annotation Examples
- Spring AOP - Application
- Spring AOP - Pointcut Methods
- Spring AOP - Before Aspect
- Spring AOP - After Advice
- Spring AOP - After Returning Advice
- Spring AOP - After Throwing Advice
- Spring AOP - Around Advice
Spring AOP Advanced
Spring AOP Useful Resources
Spring AOP - Environment Setup
This chapter will guide you on how to prepare a development environment to start your work with Spring. It will also teach you how to set up JDK on your machine before you set up spring −
Setup Java Development Kit (JDK)
You can download the latest version of SDK from Oracle's Java site − Java SE Downloads. You will find instructions for installing JDK in downloaded files, follow the given instructions to install and configure the setup. Finally set PATH and JAVA_HOME environment variables to refer to the directory that contains java and javac, typically java_install_dir/bin and java_install_dir respectively.
If you are running Windows and have installed the JDK in C:\jdk-24, you would have to put the following line in your C:\autoexec.bat file.
set PATH=C:\jdk-24;%PATH% set JAVA_HOME=C:\jdk-24
Alternatively, on Windows NT/2000/XP, you will have to right-click on My Computer, select Properties → Advanced → Environment Variables. Then, you will have to update the PATH value and click the OK button.
On Unix (Solaris, Linux, etc.), if the SDK is installed in /usr/local/jdk-24 and you use the C shell, you will have to put the following into your .cshrc file.
setenv PATH /usr/local/jdk-24/bin:$PATH setenv JAVA_HOME /usr/local/jdk-24
Alternatively, if you use an Integrated Development Environment (IDE) like Borland JBuilder, Eclipse, IntelliJ IDEA, or Sun ONE Studio, you will have to compile and run a simple program to confirm that the IDE knows where you have installed Java. Otherwise, you will have to carry out a proper setup as given in the document of the IDE.
Popular Java Editors
To write your Java programs, you need a text editor. There are many sophisticated IDEs available in the market. But for now, you can consider one of the following −
Notepad − On Windows machine, you can use any simple text editor like Notepad (Recommended for this tutorial), TextPad.
Netbeans − It is a Java IDE that is open-source and free, which can be downloaded from www.netbeans.org/index.html.
Eclipse − It is also a Java IDE developed by the eclipse open-source community and can be downloaded from www.eclipse.org.
Install Eclipse
In this chapter, we will explain how to set Spring environment in Eclipse IDE. Before proceeding with the installation, make sure that you already have Eclipse installed in your system. If not, download and install Eclipse.
For more information on Eclipse, please refer our Eclipse Tutorial
Install Maven
Download Maven 3.9.11 from https://maven.apache.org/download.cgi.
| OS | Archive name |
|---|---|
| Windows | apache-maven-3.9.11-bin.zip |
| Linux | apache-maven-3.9.11-bin.tar.gz |
| Mac | apache-maven-3.9.11-bin.tar.gz |
Extract the Maven Archive
Extract the archive, to the directory you wish to install Maven 3.9.11. The subdirectory apache-maven-3.9.11 will be created from the archive.
| OS | Location (can be different based on your installation) |
|---|---|
| Windows | C:\Program Files\Apache Software Foundation\apache-maven-3.9.11 |
| Linux | /usr/local/apache-maven |
| Mac | /usr/local/apache-maven |
Set Maven Environment Variables
Add M2_HOME, M2, MAVEN_OPTS to environment variables.
| OS | Output |
|---|---|
| Windows |
Set the environment variables using system properties. M2_HOME=C:\Program Files\Apache Software Foundation\apache-maven-3.9.11 M2=%M2_HOME%\bin MAVEN_OPTS=-Xms256m -Xmx512m |
| Linux |
Open command terminal and set environment variables. export M2_HOME=/usr/local/apache-maven/apache-maven-3.9.11 export M2=$M2_HOME/bin export MAVEN_OPTS=-Xms256m -Xmx512m |
| Mac |
Open command terminal and set environment variables. export M2_HOME=/usr/local/apache-maven/apache-maven-3.9.11 export M2=$M2_HOME/bin export MAVEN_OPTS=-Xms256m -Xmx512m |
Step 5 - Add Maven bin Directory Location to System Path
Now append M2 variable to System Path.
| OS | Output |
|---|---|
| Windows | Append the string ;%M2% to the end of the system variable, Path. |
| Linux | export PATH=$M2:$PATH |
| Mac | export PATH=$M2:$PATH |
Verify Maven Installation
Now open console and execute the following mvn command.
| OS | Task | Command |
|---|---|---|
| Windows | Open Command Console | c:\> mvn --version |
| Linux | Open Command Terminal | $ mvn --version |
| Mac | Open Terminal | machine:~ joseph$ mvn --version |
Finally, verify the output of the above commands, which should be as follows −
| OS | Output |
|---|---|
| Windows |
Apache Maven 3.9.11 (3e54c93a704957b63ee3494413a2b544fd3d825b) Maven home: C:\Program Files\Apache Software Foundation\apache-maven-3.9.11 Java version: 24.0.1, vendor: Oracle Corporation, runtime: C:\Program Files\Java\jdk-24\ Default locale: en_IN, platform encoding: Cp1252 OS name: "windows 11", version: "10.0", arch: "amd64", family: "windows" |
| Linux |
Apache Maven 3.9.11 (3e54c93a704957b63ee3494413a2b544fd3d825b) Java version: 24.0.1 Java home: /usr/local/java-current/jre |
| Mac |
Apache Maven 3.9.11 (3e54c93a704957b63ee3494413a2b544fd3d825b) Java version: 24.0.1 Java home: /Library/Java/Home/jre |