Spring Boot | IntelliJ IDEA (2023)

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. IntelliJIDEA 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

  1. From the main menu, select File | New | Project.

  2. In the left pane of the New Project wizard, select Spring Initializr.

  3. Go through the steps of the Spring Initializr project wizard.

For an example, see Tutorial: Create your first Spring application.

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, IntelliJIDEA 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 Spring Boot | IntelliJIDEA (1) in the gutter, and select to run the class.

    Spring Boot | IntelliJIDEA (2)

    Alternatively, you can press Ctrl+Shift+F10 with the class file open in the editor.

IntelliJIDEA 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 IntelliJIDEA know which files are configuration files in your project to enable relevant highlighting and coding assistance:

  1. From the main menu, select File | Project Structure or press Ctrl+Alt+Shift+S to open the Project Structure dialog.

  2. From the left-hand list, select Facets.

  3. Select the Spring facet from the list in the middle and click Spring Boot | IntelliJIDEA (3) in the right-hand section.

  4. 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 Spring Boot | IntelliJIDEA (4) and select files from the project tree.

    Valid configuration files are marked with Spring Boot | IntelliJIDEA (5).

  5. Click OK and apply the changes.

Spring Boot | IntelliJIDEA (6)

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:

    <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency>

    Open the build.gradle file and add the following dependency under dependencies:

    implementation 'org.springframework.boot:spring-boot-starter-actuator'

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

  1. Run your Spring Boot application and open the Services tool window: select View | Tool Windows | Services or press Alt+8.

  2. Select your running Spring Boot application and open the Actuator tab.

Spring Boot | IntelliJIDEA (7)

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 Spring Boot | IntelliJIDEA (8) icon in the gutter. Click this icon to view dependent and injected beans.

The Beans tab includes the following toolbar actions:

Action

Description

Spring Boot | IntelliJIDEA (9) Refresh

Refresh the runtime beans information collected by the JMX agent.

Spring Boot | IntelliJIDEA (10) Diagram Mode

Show the complete graph for all your runtime beans instead of a list.

Required plugin: Diagrams (bundled).

Spring Boot | IntelliJIDEA (11) Show Library Beans

Show beans from libraries.

Spring Boot | IntelliJIDEA (12) Show Contexts

Show available Spring application contexts.

Spring Boot | IntelliJIDEA (13) Show Configuration Files

Show available configuration files.

Spring Boot | IntelliJIDEA (14) Show Bean Documentation

Show the documentation for the selected bean.

Spring Boot | IntelliJIDEA (15) 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.

Spring Boot | IntelliJIDEA (16)

Double-click a method to open its declaration in the editor. Spring registers such methods as handlers and IntelliJIDEA indicates them with the Spring Boot | IntelliJIDEA (17) 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:

Action

Description

Spring Boot | IntelliJIDEA (18) Refresh

Refresh the request mappings collected by the JMX agent.

Spring Boot | IntelliJIDEA (19) Open in Browser

Open the root application URL in a web browser.

Spring Boot | IntelliJIDEA (20) Request Method

Select which request methods to show.

Spring Boot | IntelliJIDEA (21) 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 IntelliJIDEA 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:

    <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <optional>true</optional> </dependency>

    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:

    developmentOnly("org.springframework.boot:spring-boot-devtools")

    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 Spring Boot | IntelliJIDEA (22). Depending on your needs, you can configure what the IDE will do when you execute this action.

Configure the application update policy

  1. From the main menu, select Run | Edit Configurations.

  2. Select the necessary Spring Boot run configuration to open its settings. Click Modify options.

    Spring Boot | IntelliJIDEA (23)
  3. 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.

  4. 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.

Last modified: 21 April 2023

Spring diagrams Spring Initializr project wizard

FAQs

Is IntelliJ Community Edition enough for Spring Boot? ›

Unfortunately, IntelliJ's free community addition does not come with a Springboot plugin preinstalled. There are a few ways to connect your Java to IntelliJ free addition, and the route we will take in this article will be to create a project on SpringBoot Initialzr and importing.

How to set up IntelliJ for Spring Boot? ›

Create a new Spring Boot project
  1. From the main menu, select File | New | Project.
  2. In the left pane of the New Project wizard, select Spring Initializr.
  3. Specify a name for the project: spring-boot-tutorial . ...
  4. Select the Spring Web dependency under Web.
May 17, 2023

What are the 3 main concepts Spring Boot provides when it starts your application? ›

Java Spring Boot (Spring Boot) is a tool that makes developing web application and microservices with Spring Framework faster and easier through three core capabilities:
  • Autoconfiguration.
  • An opinionated approach to configuration.
  • The ability to create standalone applications.

How to add Spring Boot dependency in IntelliJ? ›

Add Spring Boot Actuator
  1. Open the pom. ...
  2. From the main menu, select Code | Generate Alt+Insert and then select Add dependency….
  3. In the Dependencies tool window, find and add the Spring Boot Starter Actuator dependency: org.springframework.boot:spring-boot-starter-actuator. ...
  4. Click. ...
  5. Restart your Spring application with.
May 4, 2023

Is IntelliJ community good enough? ›

The community edition is fine for basic Java development. It is suitable for desktop projects, and includes the visual GUI Builder, and also supports Maven and Ant build tools, JUnit and TestNG testing, Java and Android development, and rich editor support for Java and XML.

Is IntelliJ community better than Eclipse? ›

IntelliJ is much easier to use as compared to Eclipse. The learning curve is far faster in IntelliJ, which makes developing easier and more natural. Code completion, Dropdowns, quick view, project wizards, etc. are all possible in both Eclipse and IntelliJ, but the user experience in IntelliJ is much more satisfying.

Do we need Maven for Spring Boot? ›

Spring Boot is compatible with Apache Maven 3.6.3 or later. If you do not already have Maven installed, you can follow the instructions at maven.apache.org. On many operating systems, Maven can be installed with a package manager.

How to run IntelliJ Spring Boot without test? ›

to toggle the Skip tests mode. On the Runner page, select Skip tests and click OK. IntelliJ IDEA de-activates the test goal under the Lifecycle node. The appropriate message notifying that tests are skipped is displayed in the Run tool window when you execute other goals.

How do I run Spring Boot tests in IntelliJ? ›

Quick way
  1. Place the caret at the test class to run all tests in that class, or at the test method, and press Ctrl+Shift+F10 . ...
  2. To run all tests in a folder, select this folder in the Project tool window and press Ctrl+Shift+F10 or select Run Tests in 'folder' from the context menu .
May 3, 2023

What are the two most important modules of spring boot? ›

The Application Module includes Model Module, Service Implementation Module as dependency that contains Model Module, Repository Module, and Service API module. The Model Module contains Entities and Visual Objects to be used in the project. The Repository module contains repositories to be used in the project.

What are the 3 servers in spring boot? ›

With SpringBoot, the default embedded server is Tomcat. Other options available are Jetty and UnderTow.

How to use Spring Framework in IntelliJ? ›

Add Spring facet
  1. From the main menu, select File | Project Structure or press Ctrl+Alt+Shift+S to open the Project Structure dialog.
  2. From the left-hand list, select Modules.
  3. Select the necessary module and click. in the middle section.
  4. Select Spring from the list.
May 5, 2023

Why is IntelliJ so much better than Eclipse? ›

IntelliJ has better refactoring support than Eclipse. IntelliJ provides several features to refactor your code, such as rename, move, and delete. Eclipse does not have any in-built features to refactor your code, and you can use plugins to get the same functionality in Eclipse.

What is the difference between IntelliJ IDEA and IntelliJ IDEA CE? ›

The CE (Community Edition) supplies you with most (if not all) what you actually need to develop a real-world Android project. IntelliJ IDEA Ultimate Edition is very much worth his money if you have to use it for a wider spectrum of languages/frameworks/projects.

How much RAM is required for IntelliJ IDEA? ›

System requirements
RequirementMinimum
RAM2 GB of free RAM
CPUAny modern CPU
Disk space3.5 GB
Monitor resolution1024×768
1 more row
Apr 26, 2023

Which IDE is better than IntelliJ? ›

Eclipse IDE has 148 reviews and a rating of 4.36 / 5 stars vs IntelliJ IDEA which has 1139 reviews and a rating of 4.73 / 5 stars.

Which is better IntelliJ or Visual Studio code? ›

IntelliJ IDEA has 1139 reviews and a rating of 4.73 / 5 stars vs Microsoft Visual Studio which has 2788 reviews and a rating of 4.62 / 5 stars.

Why switch from Eclipse to IntelliJ? ›

No workspace

This means that you can work with only one project at a time. While in Eclipse you normally have a set of projects that may depend on each other, in IntelliJ IDEA you have a single project that consists of a set of modules. If you have several unrelated projects, you can open them in separate windows.

Why we use POM XML in spring boot? ›

The pom. xml is the recipe that will be used to build our project. Spring Boot provides a number of "Starter POMs" that make easy to add jars to our classpath. Our sample application has already used spring-boot-starter-parent in the parent section of the POM.

Do we need POM XML in spring boot? ›

All Spring Boot projects use spring-boot-starter-parent as a parent in pom. xml file. Parent Poms allow us to manage the following things for multiple child projects and modules: Configuration: It allows us to maintain consistency of Java Version and other related properties.

What is POM in spring boot? ›

Spring Boot Starter Parent POM allows us to manage the following things for multiple child projects and modules: Configuration: Java version and other properties. Dependency management: Version of dependencies. Default plugin configuration: This includes configurations such as build plugins.

Can I learn spring boot without knowing Java? ›

Before learning Spring Boot, you must have the basic knowledge of Spring Framework.

Can we have spring boot without annotations? ›

Therefor it is not necessary to mark it by @Configuration . So, you don't need use annotation for scan packages, because you already declared it in the xml file. Spring configures all the components required to work with MongoDB automatically. And all you need just specify host and user/pass in the aplication.

How to run Spring Boot application without SpringBootApplication? ›

Uses. It's not mandatory to put @SpringBootApplication to create a Spring Boot application, you can still use @Configuration and @EnableAutoConfiguration individually as shown in the example given in the next point.

How do I jump to tests in IntelliJ? ›

Navigate between tests and production code

In IntelliJ IDEA, you can jump between test classes and production code. In the editor, place the caret at the test class or at the test subject in the source code and press Ctrl+Shift+T (Navigate | Test Subject or Navigate | Test).

How to run Spring Boot service in IntelliJ? ›

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.

How to run Spring Boot API in IntelliJ? ›

Ultimate Spring Boot run configuration
  1. From the main menu, select Run | Edit Configurations.
  2. In the Run/Debug Configurations dialog, click. and select Spring Boot.
Feb 22, 2023

How many layers are in Spring boot? ›

The four layers in Spring Boot are as follows: Presentation Layer. Business Layer. Persistence Layer.

What is autowired in Spring boot? ›

Spring boot autowired is the feature of the spring boot framework, which was used to enable us to inject the dependency object implicitly; it is used in setter or in constructor injection internally.

How many threads does Spring boot have? ›

Maximum number of threads in Spring Boot Application

max-threads to control how many threads you want to allow. This is set to 0 by default which means- use the Tomcat default which is 200 .

Can we have two main methods in spring boot? ›

After the creation of this class, we will have two new main classes with two public static void main(String args[]) methods. As we know from Java basics, we can only have one main method in a Java application.

How many types of scopes are there in spring boot? ›

There are five types of spring bean scopes: singleton - only one instance of the spring bean will be created for the spring container.

How to use 2 databases in Spring Boot? ›

Multiple Databases in Spring Boot

The interesting part is annotating the data source bean creation method with @ConfigurationProperties. We just need to specify the corresponding config prefix. Inside this method, we're using a DataSourceBuilder, and Spring Boot will automatically take care of the rest.

What is the difference between @controller and @RestController? ›

@RestController is nothing but the shortcut to use both @Controller and @ResponseBody annotation together. In other words, @Controller is used to controller which can accept and return HTML while @RestController annotation can be used to return JSON response.

What is 3 tier architecture in spring boot? ›

As the name implies, the MVC pattern has three layers: The Model defines the business layer of the application, the Controller manages the flow of the application, and the View defines the presentation layer of the application.

How many users can spring boot handle? ›

Yes, Spring boot can handle simultaneously requests! If your servlet container is tomcat under the hood, it can handle 200 simultaneous requests.

How can I make my spring boot faster? ›

TL;DR How do I make my app go faster?
  1. Classpath exclusions from Spring Boot web starters: ...
  2. Use the spring-context-indexer . ...
  3. Don't use actuators if you can afford not to.
  4. Use Spring Boot 2.1 and Spring 5.1. ...
  5. Switch off JMX if you don't need it with spring.jmx.enabled=false (this is the default in Spring Boot 2.2)
Dec 12, 2018

What is the difference between spring boot run and start? ›

spring-boot:run runs your Spring Boot application. spring-boot:start [..] Start a spring application. Contrary to the run goal, this does not block and allows other goal to operate on the application.

How do you explain spring boot project in interview? ›

Spring Boot represents a fusion of the lightweight Spring application framework, configuration annotations, and embedded HTTP server. Made available with an auto-configuration feature, and support for Spring Initializer, Groovy, and Java, Spring Boot reduces Integration Test, Development, and Unit Test time.

Is Spring Boot easy for beginners? ›

It makes it easy to develop loosely coupled applications. It makes applications testable. Spring MVC brings loose coupling to web MVC application development with features like Dispatcher Servlet, View Resolver , etc. Spring Boot eliminates the need for manual configuration with Spring and Spring MVC.

What is the main method of Spring boot? ›

Spring Boot SpringApplication class is used to bootstrap and launch a Spring application from a Java main method. This class automatically creates the ApplicationContext from the classpath, scan the configuration classes and launch the application.

How to create first API in Spring Boot? ›

To create REST API, we need to:
  1. Create the Spring Boot Project.
  2. Configure JPA, Spring Data Source and Hibernate.
  3. Create an Entity Class.
  4. Create JPA (Java Persistence API) Data Repository layer.
  5. Create Rest Controllers and map API requests.
  6. Build and run the Project.
Mar 22, 2022

What are the dependencies required for Spring Boot application? ›

What You Need
  • About 15 minutes.
  • Java 1.8 or later.
  • Gradle 7.5+ or Maven 3.5+
  • You can also import the code straight into your IDE: Spring Tool Suite (STS) IntelliJ IDEA. VSCode.

What is the latest version of Spring Boot? ›

  • Spring Shell 3.0. 5 and 3.1. ...
  • Spring Security Kerberos 2.0. 0 available now. ...
  • Spring Cloud 2022.0. 3 (aka Kilburn) Is Available. ...
  • Spring Shell 2.1. 10, 3.0. ...
  • Spring Security Kerberos 2.0. 0-RC2 available now. ...
  • Spring Boot 3.1. 0 available now. ...
  • Spring Boot 3.0. 7 available now, fixing CVE-2023-20883. ...
  • Spring Boot 2.7.

How to start Spring Boot application from command line? ›

Quick Steps
  1. Run the Spring boot application with the java -jar command: $ java -jar target/myapplication-0.0. 1-SNAPSHOT.jar.
  2. Run the Spring boot application using Maven: $ mvn spring-boot:run.
  3. Run your Spring Boot application using Gradle.

What is the difference between IntelliJ Community Edition and Ultimate for spring? ›

Basically, the community edition supports only a few types of programming languages such as Java, Groovy, Kotlin, Scala, and Python. Ultimate edition supports Android, Swing, JavaFX, Spring Cloud, Spring, Java EE, GWT as well as other frameworks also. Community edition supports only Android, Swing, and JavaFX.

What is IntelliJ IDEA Community Edition used for? ›

IntelliJ IDEA is the leading IDE for Java and Kotlin development. It helps you stay productive with a suite of efficiency-enhancing features such as intelligent coding assistance, reliable refactorings, instant code navigation, built-in developer tools, web and enterprise development support, and much more.

How much Java is required for Spring Boot? ›

Spring Boot 3.1.0 requires Java 17 and is compatible up to and including Java 20. Spring Framework 6.0.9 or above is also required.

How to create REST API in IntelliJ Community Edition? ›

Enable REST support when creating a project
  1. Click New Project on the Welcome screen or select File | New | Project.
  2. From the Generators list, select Jakarta EE.
  3. Name the new project, select a build tool, a language you want to use, and select the REST service project template.
Jun 13, 2022

Is IntelliJ IDEA community edition free? ›

IntelliJ IDEA Community Edition and IntelliJ IDEA Edu are free and can be used without any license. You cannot upgrade to IntelliJ IDEA Ultimate: download and install it separately as described in Install IntelliJ IDEA.

What is the difference between IntelliJ IDEA Community Edition and IntelliJ IDEA Edu? ›

IntelliJ IDEA Edu has all the features of IntelliJ IDEA Community, with the addition of a special toolkit for learners and educators in the form of the EduTools plugin. It is free and open-source. Please find more details about all the learning opportunities on our website or check out the features for educators.

Is IntelliJ no longer free? ›

Community Edition is free and open-source, licensed under Apache 2.0. It provides all the basic features for JVM and Android development. IntelliJ IDEA Ultimate is commercial, distributed with a 30-day trial period.

Can IntelliJ community be used for commercial use? ›

It is developed by JetBrains (formerly known as IntelliJ) and is available as an Apache 2 Licensed community edition, and in a proprietary commercial edition. Both can be used for commercial development.

How to use IntelliJ IDEA Community Edition for Java? ›

First steps
  1. Install IntelliJ IDEA. Install and run IntelliJ IDEA for the first time.
  2. Create your first Java application. Create, run, and package a simple Java application in IntelliJ IDEA.
  3. Learn IDE features. ...
  4. Configure your project. ...
  5. Write the source code. ...
  6. Get support and assistance.

What is the average salary of Java Spring Boot? ›

Java Spring Boot Developer salary in India ranges between ₹ 1.8 Lakhs to ₹ 12.0 Lakhs with an average annual salary of ₹ 4.2 Lakhs. Salary estimates are based on 157 latest salaries received from Java Spring Boot Developers.

How difficult is Java Spring Boot? ›

The Spring Framework requires a steep learning curve. It also has a complicated toolset, making it a difficult framework for relatively inexperienced development teams. Users can access lots of documentation and tutorials on the Spring Framework website and elsewhere on the internet.

How do I run backend code in IntelliJ? ›

Start the debugger from the built-in Terminal or from the Run or Debug tool window
  1. Open the embedded Terminal ( Alt+F12 ) and, type: node --inspect-brk <path to the starting page of your application relative to the project root>
  2. Launch a script from package.
Apr 21, 2023

How to run Spring Boot REST service in IntelliJ? ›

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.

References

Top Articles
Latest Posts
Article information

Author: Errol Quitzon

Last Updated: 12/12/2023

Views: 6608

Rating: 4.9 / 5 (59 voted)

Reviews: 90% of readers found this page helpful

Author information

Name: Errol Quitzon

Birthday: 1993-04-02

Address: 70604 Haley Lane, Port Weldonside, TN 99233-0942

Phone: +9665282866296

Job: Product Retail Agent

Hobby: Computer programming, Horseback riding, Hooping, Dance, Ice skating, Backpacking, Rafting

Introduction: My name is Errol Quitzon, I am a fair, cute, fancy, clean, attractive, sparkling, kind person who loves writing and wants to share my knowledge and understanding with you.