Spring Boot
Spring Boot is an extension of the Spring framework that simplifies the initial configuration of Spring applications. It enables you to quickly create a working standalone Spring application with minimum default configuration.
Spring Initializr is a web application that can generate a Spring Boot project. You can select the necessary configuration, including the build tool, language, version of the Spring Boot framework, and any dependencies for your project. IntelliJ IDEA provides the Spring Initializr project wizard that integrates with the Spring Initializr API to generate and import your project directly from the IDE.
Create a new Spring Boot project via the Spring Initializr wizard
From the main menu, select File | New | Project .
In the left pane of the New Project wizard, select Spring Initializr .
Spring Initializr generates a valid project structure with the following files:
A build configuration file, for example, build.gradle for Gradle or pom.xml for Maven.
A class with the main() method to bootstrap the application.
An empty JUnit test class.
An empty Spring application configuration file: application.properties
By default, IntelliJ IDEA applies code formatting to the generated files. If you want the files to remain formatted as they are generated by Spring Initializr , open the IDE settings with Ctrl+Alt+S , select Languages & Frameworks | Spring | Spring Initializr and disable the Reformat code when creating a new project option.
Run a Spring Boot application
Open the class with the main() method (it is usually also designated with the @SpringBootApplication annotation), click in the gutter, and select to run the class.

Alternatively, you can press Ctrl+Shift+F10 with the class file open in the editor.
IntelliJ IDEA creates and executes the Spring Boot run configuration. For more information, see Spring Boot run configuration.
Custom configuration files
Spring Initializr creates one default configuration file that may not always be sufficient for development. If you do not want to use the default configuration file, or if you want to run your code in different environments, you can use custom configuration files defined in your project.
Let IntelliJ IDEA know which files are configuration files in your project to enable relevant highlighting and coding assistance:
From the main menu, select File | Project Structure or press Ctrl+Alt+Shift+S to open the Project Structure dialog.
From the left-hand list, select Facets .
Select the Spring facet from the list in the middle and click in the right-hand section.
If you want to use a custom configuration file instead of the default one, type its name in the spring.config.name field.
If you want to use multiple configuration files, click and select files from the project tree.
Valid configuration files are marked with .
Click OK and apply the changes.
Some custom configuration files are detected automatically. For example, profile-specific configuration files with names that match the current naming pattern will be added to the context.
Runtime endpoints
Spring Boot includes additional features for monitoring and managing the state of your application in the production environment through HTTP endpoints or with Java Management Extensions (JMX). For more information, see Spring Boot Actuator: Production-ready Features.
Enable the Spring Boot actuator endpoints
Add the Spring Boot Actuator dependency for your project.
Open the pom.xml file and add the following dependency under dependencies :
Open the build.gradle file and add the following dependency under dependencies :
When you run your application with this dependency, you will be able to access the exposed actuator endpoints via HTTP. For example, if the application is running on localhost port number 8080, the default URL for the health endpoint will be http://localhost:8080/actuator/health.
View the Spring Boot actuator endpoints
Run your Spring Boot application and open the Services tool window: select View | Tool Windows | Services or press Alt+8 .
Select your running Spring Boot application and open the Actuator tab.
If the Spring Boot run configurations are not available in the Services tool window, either add them or use the Run or Debug tool window.
You can use tabs to view endpoints of the following types: runtime beans, health information, and request mappings.
Beans
The Beans tab under Actuator shows the runtime beans of your Spring Boot application. Double-click any bean to open its declaration in the editor. These beans are indicated using the icon in the gutter. Click this icon to view dependent and injected beans.
The Beans tab includes the following toolbar actions:
Refresh the runtime beans information collected by the JMX agent.
Show the complete graph for all your runtime beans instead of a list.
Required plugin: Diagrams (bundled).
Show Library Beans
Show beans from libraries.
Show Configuration Files
Show available configuration files.
Show Bean Documentation
Show the documentation for the selected bean.
Show Bean Graph
Show the direct dependencies for the selected bean.
Required plugin: Diagrams (bundled).
Health
The Health tab under Actuator shows the status of your application. There are some auto-configured health indicators and you can also write custom health indicators.
For more information, see Health.
Mappings
The Mappings tab under Actuator shows the request mappings of your application. It lists all methods with the @RequestMapping annotation or its shortcuts, such as @GetMapping .
If you click the path mapping URI, you can select to run the corresponding HTTP request, open an HTTP requests file with the request, or open the request URL in the web browser (if it’s a GET request). For more information, see HTTP Client.

Double-click a method to open its declaration in the editor. Spring registers such methods as handlers and IntelliJ IDEA indicates them with the icon in the gutter. Click this icon to run the corresponding HTTP request, open it in a requests files, or in the web browser (if it’s a GET request).
The Mappings tab includes the following toolbar actions:
Refresh the request mappings collected by the JMX agent.
Open in Browser
Open the root application URL in a web browser.
Select which request methods to show.
Show Library Mappings
Show request mappings from libraries.
Application update policies
With the spring-boot-devtools module, your application will restart every time files on the classpath change. If IntelliJ IDEA is configured to continuously compile changed files, you can set a trigger file. In this case your application will restart only after you modify the trigger file. For more information, see Automatic Restart.
Enable automatic restart
Add the spring-boot-devtools module dependency for your project.
Open the pom.xml file and add the following dependency under dependencies :
Setting the spring-boot-devtools dependency as optional prevents it from being used in other modules that use your project.
Open the build.gradle file and add the following dependency under dependencies :
Setting the spring-boot-devtools dependency as developmentOnly prevents it from being used in other modules that use your project.
To update a running application, select Run | Debugging Actions | Update Running Application Ctrl+F10 from the main menu, or select your application in the Services tool window and click . Depending on your needs, you can configure what the IDE will do when you execute this action.
If the Spring Boot run configurations are not available in the Services tool window, either add them or use the Run or Debug tool window.
Configure the application update policy
From the main menu, select Run | Edit Configurations .
Select the necessary Spring Boot run configuration to open its settings. Click Modify options .
In the list that opens, point to On ‘Update’ action . You can choose to update only the resources, update both the classes and the resources (build your application), update the trigger file (which will trigger a restart), or try to perform a class hot swap, and if it fails, update the trigger file.
For the Update trigger file and the Hot swap classes and update trigger file if failed policies, the IDE sets a trigger file when you start the application.
In the Modify options list, point to On frame deactivation and select an action that the IDE will do after you switch to another application: update the resources, or build your application.
You can create several Spring Boot run/debug configurations with different update policies and switch between them.
Spring Initializr project wizard
Use the Spring Initializr project wizard to generate a new Spring Boot project in IntelliJ IDEA.
From the main menu, select File | New | Project .
In the New Project dialog, select Spring Initializr .
Step 1. Basic project configuration

Use the default https://start.spring.io/ service or specify a custom instance. For more information, see Creating your own instance.
Specify a name for your project.
Specify the path to the directory in which you want to create the project. By default, the IDE creates a directory with the same name as the project.
Select the language that you want to use in your application.
Select the build tool to use for managing dependencies, testing, packaging, automating the build process, and so on: Maven or Gradle .
Specify the unique group identifier for your project. It should preferably start with the reversed domain name you control (for example, com.example ).
Specify a name for the artifact within the group, usually the project’s name.
Specify the root package of the project. This is usually a combination of the group and artifact names, for example: com.example.springdemo .
From the JDK list, select the JDK that you want to use in your project.
If the JDK is installed on your computer, but not defined in the IDE, select Add JDK and specify the path to the JDK home directory.
If you don’t have the necessary JDK on your computer, select Download JDK .
Select the Java version that the initializing service should use.
Select whether you want to package the app as a JAR or WAR.
Step 2. Spring Boot dependencies

Select the Spring Boot version.
Download pre-built shared indexes for JDK and Maven libraries
Silently download the pre-built shared indexes for JDK and Maven libraries instead of building the indexes. For more information, see Shared indexes.
Select starters and dependencies for your project. If you select technologies that require additional plugins, the IDE will notify you about it once the project is created, and will suggest installing or enabling them.
Spring initializer intellij idea как установить
Java language is one of the most popular languages among all programming languages. There are several advantages of using the java programming language, whether for security purposes or building large distribution projects. One of the advantages of using Java is that it tries to connect every concept in the language to the real world with the help of the concepts of classes, inheritance, polymorphism, etc.
There are several other concepts present in java that increase the user-friendly interaction between the java code and the programmer such as generic, Access specifiers, Annotations, etc these features add an extra property to the class as well as the method of the java program. In this article, In this article, we will discuss how to change the port number in the spring boot.
Note: First we need to establish the spring application in our project.
Spring Initializr is a web-based tool using which we can easily generate the structure of the Spring Boot project. It also provides various different features for the projects expressed in a metadata model. This model allows us to configure the list of dependencies that are supported by JVM. Here, we will create the structure of an application using a spring initializr and do the following steps.
Steps:
- Go to Spring Initializr
- Fill in the details as per the requirements
- Click on Generate which will download the starter project
- Extract the zip file
- Create a java class with the name Controller and add the annotation
- Go to the Postman and add URL address and make put request
These steps are sequentially described below with visual aids as follows:
Step 1: Go to Spring Initializr
Step 2: Fill in the details as per the requirements. For this application:
Step 3: Click on Generate which will download the starter project.
Step 4: Extract the zip file. Now open a suitable IDE and then go to File->New->Project from existing sources->Spring-boot-app and select pom.xml. Click on import changes on prompt and wait for the project to sync.
Note: In the Import Project for Maven window, make sure you choose the same version of JDK which you selected while creating the project.
Java Spring Boot + IntelliJ IDEA

To those who develop in java nowadays, it’s almost impossible to miss Spring framework and more specifically Spring Boot. Using this development stack, we gain more productivity and agility from small to large sized java projects. In this guide I’ll demonstrate how to install, configure IntelliJ IDEA and create a simple Hello-World using java, IntelliJ IDEA and spring boot.
The github repository of the example project of this post, can be found at: https://github.com/danielpadua/java-spring-idea-example
Requirements
- Java JDK 8 or higher
Installing IntelliJ IDEA
Use the following sections based in which operational system you’ll be using:
Windows
In Windows we have 2 options:
Go to jetbrains download page, select the latest version (on the writing date of this guide is the 2019.1.1) and install it using NNF (next, next and finish).
If you don’t know Chocolatey, take a look at this post.
Open powershell and install IntelliJ IDEA using the following command line:
Linux
In Linux we also have 2 options:
Go to jetbrains download page, select the latest version (on the writing date of this guide is the 2019.1.1), extract the .tar.gz file and execute the /bin/idea.sh file.
Depending in which Linux distro you are using, you’ll use a different package manager. For instance, debian based distros, like the popular ubuntu, use apt-get. For Red Hat (or RHEL) based distros use yum or dnf. Search the best way to install IntelliJ IDEA using your package manager.
macOS
In macOS we have 2 options again:
Go to jetbrains download page, select the latest version (on the writing date of this guide is the 2019.1.1) and install it as usual, dragging the app from the .dmg file to the apps folder of your mac.
If you don’t know Homebrew, take a look at this post
Open your favorite terminal and install IntelliJ IDEA using the following command line:
Configuring IntelliJ IDEA
With IntelliJ IDEA installed, the configuration is pretty simple. When you execute IDEA you will be questioned about some configurations like: theme color, shortcut key mapping and plugins. Let’s leave default config and begin.
Creating the project
As soon as it starts, you’ll see the following screen:
IntelliJ IDEA initial screen
For this example, we’ll be using Maven as build-tool.
Unfortunately using IntelliJ IDEA Community, according to the documentation, there’s no support to create Spring Boot projects using Spring Initializr through the IDE in Community version, only in the Ultimate Edition. So, we have two choices that we can explore:
Use Spring Initializr Web
Access: https://start.spring.io, and fill the fields like below:
Configuring project creation in Spring Initializr
Don’t forget to select Web as dependency. Click Generate Project to download the project zip file. Extract it to a directory of your choice, go back to IntelliJ IDEA and select Import Project. Navigate to project’s directory and select the pom.xml file. You’ll see a window that is responsible for importing the Maven project, leave the defaults configs:
Import Spring Initializr project
Select the project to import and click next:
Select the project
In the next screen, set the JDK version that you installed:
Select the JDK version for the project
In the next screen confirm the project name and click finish.
Creating a Maven project and add Spring manually
In IntelliJ IDEA’s initial screen, select Create New Project, located on the left side tab and select Maven, on the right side, select the JDK version and click next:
Creating a Maven project
When selecting the archetype, IntelliJ IDEA will assume that you will use Quickstart archetype, which is ok for our goal.
In the next screen specify the GroupId, ArtifactId and the Version and click next:
Maven configuration
After you just have to name your project and click finish:
Naming the project
With the project created, configure pom.xml according to the following snippet:
After updating pom.xml a notification will pop-up at the bottom right corner of the screen:
Import pom.xml changes
Click Import Changes for Maven refresh all project dependencies.
Now we’ll create a class that will contain the main function of the project. Remember that creating a class in default package is not a good java practice, so, click in source folder main/java and create a package:
Creating a package
Write the name of the package, in my example was: br.com.danielpadua.java_spring_idea_example , and create a class inside this package named ExampleApplication.java , and write the following code:
Don’t forget the unit tests main class too, repeat package creation step and create a class named: ExampleApplicationTests.java and write the code:
At this moment we’ll have basically the same project structure that is generated by Spring Initializr at the section above.
Completing the project
With the basic project skeleton created, we just have to create a package to nest the controller that will contain Hello World endpoint. Right click the root package:
Creating a package for the controllers
Write: controllers and confirm. Inside the generated package, create a class named: ExampleController.java and write the code:
Run the project by right clicking over the main class Application.java and select the option Run ‘Application.main()’ :
Running the app
After clicking run, you should see the output in the Run tab located at screen’s bottom:
Spring initialization log
To test the app, you only have to open your favorite browser and access: http://localhost:8080/api/example/hello-world, and you should see the Hello World message:
Voilá
Conclusion
IntelliJ IDEA is the most used IDE for java nowadays and it’s probably the most complete in the opinion of many developers. Community version is a great alternative to traditional eclipse.