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
172
votes
10 answers

Java Spring Boot: How to map my app root (“/”) to index.html?

How can I map my app root http://localhost:8080/ to a static index.html? If I navigate to http://localhost:8080/index.html its works fine. My app structure is : My config\WebConfig.java looks like…
Shoham
  • 7,014
  • 8
  • 40
  • 40
172
votes
14 answers

Spring Boot + JPA : Column name annotation ignored

I have a Spring Boot application with dependency spring-boot-starter-data-jpa. My entity class has a column annotation with a column name. For example: @Column(name="TestName") private String testName; SQL generated by this created test_name as the…
Kamil
  • 2,158
  • 2
  • 18
  • 19
171
votes
1 answer

How to determine programmatically the current active profile using Spring boot

Is there a way programmatically to get the current active profile within my bean?
rayman
  • 20,786
  • 45
  • 148
  • 246
169
votes
28 answers

Spring Boot: Cannot access REST Controller on localhost (404)

I am trying to adapt the REST Controller example on the Spring Boot website. Unfortunately I've got the following error when I am trying to access the localhost:8080/item URL. { "timestamp": 1436442596410, "status": 404, "error": "Not…
mchlfchr
  • 3,998
  • 4
  • 26
  • 35
163
votes
23 answers

Disable Logback in SpringBoot

It appears Springboot autoconfigures itself to use Logback with Tomcat. I would like to disable this and use the one I provide in my classpath. The error message below. LoggerFactory is not a Logback LoggerContext but Logback is on the classpath.…
F.O.O
  • 4,730
  • 4
  • 24
  • 34
162
votes
20 answers

How to shutdown a Spring Boot Application in a correct way?

In the Spring Boot Document, they said that 'Each SpringApplication will register a shutdown hook with the JVM to ensure that the ApplicationContext is closed gracefully on exit.' When I click ctrl+c on the shell command, the application can be…
Chris
  • 6,431
  • 10
  • 44
  • 59
159
votes
10 answers

Spring Boot Adding Http Request Interceptors

What is the right way to add HttpRequest interceptors in spring boot application? What I want to do is log requests and responses for every http request. Spring boot documentation does not cover this topic at all.…
hrishikeshp19
  • 8,838
  • 26
  • 78
  • 141
156
votes
14 answers

Spring-boot default profile for integration tests

Spring-boot utilizes Spring profiles which allows to have separate config for different environments. One way I use this feature is to configure the test database to be used by integration tests. I wonder, however: is it necessary to create my own…
Piotr Zakrzewski
  • 3,591
  • 6
  • 26
  • 28
156
votes
19 answers

Spring @PropertySource using YAML

Spring Boot allows us to replace our application.properties files with YAML equivalents. However, I seem to hit a snag with my tests. If I annotate my TestConfiguration (a simple Java config), it is expecting a properties file. For example this…
checketts
  • 14,167
  • 10
  • 53
  • 82
155
votes
5 answers

Programmatically shut down Spring Boot application

How can I programmatically shutdown a Spring Boot application without terminating the VM? In other works, what is the opposite of new SpringApplication(Main.class).run(args);
Axel Fontaine
  • 34,542
  • 16
  • 106
  • 137
151
votes
17 answers

Spring Boot without the web server

I have a simple Spring Boot application that gets messages from a JMS queue and saves some data to a log file, but does not need a web server. Is there any way of starting Spring Boot without the web server?
Michael
  • 13,838
  • 18
  • 52
  • 81
151
votes
7 answers

Spring Boot Rest Controller how to return different HTTP status codes?

I am using Spring Boot for a simple REST API and would like to return a correct HTTP statuscode if something fails. @RequestMapping(value="/rawdata/", method = RequestMethod.PUT) @ResponseBody @ResponseStatus( HttpStatus.OK ) public RestModel…
Marco
  • 15,101
  • 33
  • 107
  • 174
150
votes
20 answers

How to set the max size of upload file

I'm developing application based on Spring Boot and AngularJS using JHipster. My question is how to set max size of uploading files? If I'm trying to upload to big file I'm getting this information in console: DEBUG 11768 --- [io-8080-exec-10]…
Michał Styś
  • 1,743
  • 3
  • 12
  • 16
150
votes
16 answers

JSON Java 8 LocalDateTime format in Spring Boot

I'm having a small problem with formatting a Java 8 LocalDateTime in my Spring Boot Application. With 'normal' dates I have no problem, but the LocalDateTime fields are converted to the following: "startDate" : { "year" : 2010, "month" :…
Erik Pragt
  • 13,513
  • 11
  • 58
  • 64
147
votes
13 answers

How to start up spring-boot application via command line?

I have a spring-boot application which I need to start up by going to the folder directory and start up my web application via command line. I have a class called Application.java and the code inside it is as…
user4900074
  • 1,695
  • 4
  • 18
  • 24