SPRING BOOT Install IntelliJ
SPRING BOOT
Spring Boot is the most popular Java framework for enterprise Java application development, and IntelliJ IDEA provides a powerful development environment for building any type of Spring Boot application, from simple to complex.
IntelliJ IDE.
➔ IntelliJ IDEA provides many tools and functionalities to enhance the capabilities of developers.
➔ Spring Boot provides minimal configuration for building applications, and creating a project in IntelliJ IDEA is very easy and efficient.
➔ IntelliJ has a wizard for creating a Spring Boot project, which helps developers create a project in a matter of seconds. In addition, a project can also be created from the Spring Initializer.
➔ For projects created outside of IntelliJ using the Spring Initializer, the project must be unzipped to a specific location and this project can be opened and edited with IntelliJ.
Installing IntelliJ.
➔ To install IntelliJ Idea on the Windows platform, the software must be downloaded from JetBrains' official site. JetBrains Download Page.
➔ Open the .exe file to launch the setup and follow the wizard's instructions during the installation.
➔ If prompted, restart the computer system to complete the environment path configuration.
Download IntelliJ from the official website IntelliJ Download Page.
Open .exe file as administrator to launch installation wizard.
Welcome,Click Next to continue the installation.
Choose install location, Click Next to continue the installation.
Check create desktop shortcut and update PATH variable, Click Next to continue the installation.
Click Install to continue the installation.
Wait until the window completes its task.
Click Finish and open IntelliJ from the Start menu.
Accept the agreement when prompted.
Allow the firewall if requested.
Skip or import settings from VS Code.
There are two main ways to create a Spring Boot project.
1) Inside IntelliJ and 2)Outside IntelliJ.
➔ Inside IntelliJ: To create a Spring Boot project using the IntelliJ wizard, follow these steps.
Select Projects -> New Project.
Select Spring Boot and complete the project settings and click Next.
Select project dependency settings and click Create.
Spring Web and Spring Boot DevTools have been added for simple HelloWorld project.
Create Class HelloController.java
Right Click on package -> New -> Java Class
Code for Controller class
HelloController.java
package com.exam.helloworld;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping(value = "/api")
public class HelloController {
@GetMapping(value = "/hello")
public String helloHandler() {
return "Spring Boot is working fine";
}
}
Change the server port if there is a port conflict
By default, the Tomcat server runs on port 8080, so change the server port if there is a port conflict with another server that has the same port (8080).
Run the Spring Boot application.
➔ Right-click on the class annotated with @SpringBootApplication and select Run (this is a common way to run Spring Boot Application).
➔ Spring Boot applications can be run in multiple ways, no matter how they are run, the results of all methods are the same.
Verify that the application is actually running successfully.
Check if the Spring Boot application is working properly.
Spring Boot requirements
➔ Spring Boot requires JDK, JDK version dependencies can be verified from Spring's official website. Spring Boot System Requirements.
➔ JDK Automatic Setup: IntelliJ IDE can be setup to install the JDK automatically. To do this, go to File > Project Structure > SDKs and if the required version of JDK is not already installed, select 'download JDK'.
➔ JDK Manual Setup: Alternatively, the required version of JDK can be downloaded and installed from the Oracle website. Once the installation is complete, point IntelliJ to the JDK installation directory.
Download the Java Development Kit (JDK)
➔ To download the JDK, go to the Oracle Java Release page Java Releases or download the latest JDK.
➔ Select the appropriate version according to the platform (windows/Linux/Mac).
➔ You may be asked to log in to download the JDK, please log in. If you don't have an Oracle account, create one and complete the download process.
Java Development Kit (JDK) Installation:
➔ To launch the setup wizard, double-click the downloaded jdk .exe file and follow the wizard's instructions until the installation is complete. This is a very simple process.
➔ To check if the installation was successful, issue the java -version command in the terminal. This will show the Java version installed on the system.
Check Java version installed in the system.
To create a Spring Boot project using Spring Initializr outside of IntelliJ, you generally need to follow the following steps.
➔ Generate the project: Create the project using Spring Initializr from Spring Initializr and generate the project zip file.
➔ Unzip the project: Unzip the project to a location of your choice.
➔ Open the project: Open the project with IntelliJ and start editing and coding for the project.