Setting up Development Environment
1. Install JDK for Java 8 or higher
2. Have Java IDE installed
If you have decided to get into Spring, I assume you already are using an IDE of your preference. Although it doesn't matter which IDE you use, I personally use IntelliJ here.
3. Install Tomcat
For Java application server, we will be using Tomcat.
First, go to tomcat.apache.org and install Tomcat 9. Be aware, we need version 9 here, not the other ones. Download Tomcat using Windows Service Installer.
Next, install Tomcat by running the installer. Select Full for the type of install. For configuration, we can leave it as it is in default.
After the installation is completed, check on run apache tomcat, close the installer, and verify the installation by running the page http://localhost:8080. If you are directed to the page below, then it means Tomcat has been installed successfully.
4. Download Spring 5 JAR files
Visit Spring repo by clicking here. Click on Artifacts section on the left sidebar.
From there, go to libs-release > org > springframework > spring, and click on the latest version of Spring. Download spring-5.3.8-dist.zip (version number may differ) using url-to-file.
After the zip file is downloaded, unzip the files, and go to libs folder. Copy all of the jar files inside the folder.
Now, open Intellij and create a new Java project (not Java web application). Create a folder called 'lib' at the root directory of the project, and paste all of the jar files that were copied from the libs folder of the unzipped Spring folder previously. It should look like this:
Additionally, we need to add these JAR files to the build path. We do this in IntelliJ by navigating to File - Project Structure - Modules. Click on Dependencies tab, and click on the plus sign at the right corner. Click on Jar or Directories, navigate to the directory where all the JAR files are downloaded, select all of the JAR files, and click on OK.
After this step, the JAR files are now successfully added to build path.
5. Set up Tomcat in IntelliJ
The final step is setting up Tomcat server in IntelliJ. In IntelliJ, navigate to Run - Edit Configurations. Click on the plus sign at the top left corner, scroll down and click on Tomcat Server - Local.
In the popup, click on the folder icon for Tomcat Home, where you need to locate the directory where Tomcat is installed at.
* If a warning appears that the selected directory is not a valid tomcat home, this is because the folder is inaccessible due to lack of permission. To figure this out, open the root folder of Tomcat, double click on the folder, and authorise permissions. After doing this, try this step again, and it should work without problems.
After taking all of the steps above, you will be able to see that the Tomcat server is connected.
That was it, now we are ready to start with Spring!
Comments
Post a Comment