Questions tagged [spring-boot]

Use the Spring Boot tag for questions related to spring boot framework and the features it brings to your Web application. This includes questions about configuration, embedding of the Web servers, setting up metrics, health checks, externalized configuration etc. It does not include questions about the Web server itself, Java code running in your application, or standard spring components. Tag these questions with its own tags to get the best response!

Spring Boot makes it very easy to create a Spring-powered application with a minimum amount of work. An application created with Spring Boot (you can quickly do it using Spring Initializr) can be:

  • Created without a single line of configuration,
  • Created without any requirement of an application server because Spring Boot provides an application server (Embed , or ).
  • Largely autoconfigured with some sensible defaults and opinionated starter POMs to simplify your configuration,
  • Provide production-ready features such as metrics, health checks, and externalized configuration.

Spring Boot consists of several (optional) modules

Spring Boot CLI

A command line interface, based on , for starting/stopping Spring Boot created applications.

Spring Boot Core

The base for other modules, but it also provides some functionality that can be used on its own, eg. using command line arguments and files as Spring Environment property sources and automatically binding environment properties to Spring bean properties (with validation).

Spring Boot Autoconfigure

Module to autoconfigure a wide range of Spring projects. It will detect the availability of certain frameworks ( , , , ). When detected it will try to automatically configure that framework with some sensible defaults, which in general can be overridden in an application.properties/.yml file.

Spring Boot Actuator

This project, when added, will enable certain enterprise features (Security, Metrics, Default Error pages) to your application. Like the auto configure module it uses autodetection to detect certain frameworks/features of your application.

Spring Boot Starters

Different quickstart projects to include as a dependency in your or build file. It will have the needed dependencies for that type of application. Currently, there are starter projects for a web project ( and based), , , , exist. Many more have been added over the years and the full list can be found here.

Spring Boot Tools

The and build tool, as well as the custom Spring Boot Loader (used in the single executable jar/war), is included in this project.

143171 questions
279
votes
11 answers

Difference between Spring MVC and Spring Boot

I have just started learning Spring. In my next step, I would like to develop bigger web applications. Now I am wondering if I should start with Spring Boot or Spring MVC. I have already read some stuff, but it is confusing because both look…
Gero
  • 12,993
  • 25
  • 65
  • 106
271
votes
4 answers

What is this spring.jpa.open-in-view=true property in Spring Boot?

I saw spring.jpa.open-in-view=true property in Spring Boot documentation for JPA configuration. Is the true default value for this property if it's not provided at all?; What does this really do? I did not find any good explaining for it; Does it…
Carlos Alberto
  • 7,761
  • 13
  • 52
  • 72
254
votes
23 answers

Why does my Spring Boot App always shutdown immediately after starting?

This is my first Spring Boot code. Unfortunately, it always shuts down. I was expecting it to run continuously so that my web client can get some data from the browser. package hello; import org.springframework.boot.*; import…
johnsam
  • 4,192
  • 8
  • 39
  • 58
253
votes
4 answers

Difference between @Mock, @MockBean and Mockito.mock()

When creating tests and mocking dependencies, what is the difference between these three approaches? @MockBean: @MockBean MyService myservice; @Mock: @Mock MyService myservice; Mockito.mock() MyService myservice = Mockito.mock(MyService.class);
Doug
  • 5,661
  • 2
  • 26
  • 27
252
votes
33 answers

Spring boot - Not a managed type

I use Spring boot+JPA and having a problem while starting the service. Caused by: java.lang.IllegalArgumentException: Not an managed type: class com.nervytech.dialer.domain.PhoneSettings at…
user1578872
  • 7,808
  • 29
  • 108
  • 206
241
votes
10 answers

Spring Boot YAML configuration for a list of strings

I am trying to load an array of strings from the application.yml file. This is the config: ignore: filenames: - .DS_Store - .hg This is the class fragment: @Value("${ignore.filenames}") private List igonoredFileNames =…
Bahadır Yağan
  • 5,577
  • 3
  • 35
  • 39
234
votes
16 answers

Unable to find a @SpringBootConfiguration when doing a JpaTest

I'm trying to run a simple Junit test to see if my CrudRepositories are indeed working. The error I keep getting is: Unable to find a @SpringBootConfiguration, you need to use @ContextConfiguration or @SpringBootTest(classes=...) with your…
Thomas Billet
  • 2,381
  • 2
  • 13
  • 13
233
votes
36 answers

Spring Boot - Cannot determine embedded database driver class for database type NONE

This is the error that is thrown when trying to run my web app: [INFO] WARNING: Nested in org.springframework.beans.factory.BeanCreationException: Error creating bean with name…
quarks
  • 33,478
  • 73
  • 290
  • 513
228
votes
54 answers

Consider defining a bean of type 'package' in your configuration [Spring-Boot]

I am getting the following error: *************************** APPLICATION FAILED TO START *************************** Description: Parameter 0 of method setApplicant in webService.controller.RequestController required a bean of type…
Mike3355
  • 11,305
  • 24
  • 96
  • 184
227
votes
22 answers

Add context path to Spring Boot application

I am trying to set a Spring Boot applications context root programmatically. The reason for the context root is we want the app to be accessed from localhost:port/{app_name} and have all the controller paths append to it. Here is the application…
CorreyS
  • 2,433
  • 3
  • 15
  • 16
216
votes
26 answers

Spring Boot not serving static content

I can't get my Spring-boot project to serve static content. I've placed a folder named static under src/main/resources. Inside it I have a folder named images. When I package the app and run it, it can't find the images I have put on that…
Vinicius Carvalho
  • 3,994
  • 4
  • 23
  • 29
215
votes
3 answers

Spring Boot - parent pom when you already have a parent pom

Is there a specific recommended approach to the inclusion of the spring-boot parent pom into projects that already have a required parent POM? What do you recommend for projects that need to extend from an organizational parent (this is extremely…
Scott C.
  • 3,672
  • 4
  • 18
  • 20
214
votes
20 answers

Spring Boot application as a Service

How to configure nicely Spring Boot application packaged as executable jar as a Service in the Linux system? Is this recommended approach, or should I convert this app to war and install it into Tomcat? Currently, I can run Spring boot application…
MariuszS
  • 30,646
  • 12
  • 114
  • 155
209
votes
11 answers

How do I tell Spring Boot which main class to use for the executable jar?

Execution default of goal org.springframework.boot:spring-boot-maven-plugin:1.0.1.RELEASE:repackage failed: Unable to find a single main class from the following candidates My project has more than one class with a main method. How do I tell the…
Thilo
  • 257,207
  • 101
  • 511
  • 656
206
votes
6 answers

How do I retrieve query parameters in a Spring Boot controller?

I am developing a project using Spring Boot. I've a controller which accepts GET requests. Currently I'm accepting requests to the following kind of URLs: http://localhost:8888/user/data/002 but I want to accept requests using query…
Mehandi Hassan
  • 2,381
  • 4
  • 16
  • 20