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
1046
votes
62 answers

How to configure port for a Spring Boot application

How do I configure the TCP/IP port listened on by a Spring Boot application, so it does not use the default port of 8080.
Paul Verest
  • 60,022
  • 51
  • 208
  • 332
544
votes
31 answers

How to access a value defined in the application.properties file in Spring Boot

I want to access values provided in application.properties, e.g.: logging.level.org.springframework.web: DEBUG logging.level.org.hibernate: ERROR logging.file=${HOME}/application.log userBucket.path=${HOME}/bucket I want to access userBucket.path…
Qasim
  • 9,058
  • 8
  • 36
  • 50
516
votes
24 answers

How can I log SQL statements in Spring Boot?

I want to log SQL statements to a file. I have the following properties in…
Oleg Pavliv
  • 20,462
  • 7
  • 59
  • 75
461
votes
18 answers

Spring Boot: How can I set the logging level with application.properties?

This is very simple question, but I cannot find information. (Maybe my knowledge about Java frameworks is severely lacking) How can I set the logging level with application.properties? And logging file location, etc?
zeodtr
  • 10,645
  • 14
  • 43
  • 60
425
votes
6 answers

What is the purpose of mvnw and mvnw.cmd files?

When I created a Spring Boot application I could see mvnw and mvnw.cmd files in the root of the project. What is the purpose of these two files?
shaunthomas999
  • 5,544
  • 2
  • 26
  • 30
416
votes
19 answers

Running code after Spring Boot starts

I want to run code after my spring-boot app starts to monitor a directory for changes. I have tried running a new thread but the @Autowired services have not been set at that point. I have been able to find ApplicationPreparedEvent, which fires…
stewsters
  • 4,335
  • 3
  • 15
  • 7
367
votes
9 answers

What is the difference between putting a property on application.yml or bootstrap.yml in spring boot?

What is the difference between putting a property on application.yml or bootstrap.yml in spring boot? In logging.config case, the application works differently.
Rys
  • 4,934
  • 8
  • 21
  • 37
356
votes
37 answers

org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set

I am trying run a spring-boot application which uses hibernate via spring-jpa, but i am getting this error: Caused by: org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set at…
Kleber Mota
  • 8,521
  • 31
  • 94
  • 188
327
votes
48 answers

Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured

I am working on a Spring Boot Batch example with MongoDB and I have already started the mongod server. When I launch my application, I am getting the error below. Any pointers for this issue? *************************** APPLICATION FAILED TO…
Jeff Cook
  • 7,956
  • 36
  • 115
  • 186
327
votes
10 answers

Spring Boot configure and use two data sources

How can I configure and use two data sources? For example, here is what I have for the first data source: application.properties #first db spring.datasource.url = [url] spring.datasource.username = [username] spring.datasource.password =…
juventus
  • 3,282
  • 3
  • 11
  • 7
308
votes
16 answers

Setting active profile and config location from command line in Spring Boot

I have a Spring Boot application. I have three profiles in my application-> development, staging and production. So I have 3 files application-development.yml application-staging.yml application-production.yml My application.yml resides inside…
Vinod Mohanan
  • 3,729
  • 2
  • 17
  • 25
295
votes
22 answers

Spring Boot - Loading Initial Data

I'm wondering what the best way to load initial database data before the application starts? What I'm looking for is something that will fill my H2 database with data. For example, I have a domain model "User" I can access users by going to /users…
Lithicas
  • 3,793
  • 7
  • 23
  • 32
291
votes
18 answers

How do I activate a Spring Boot profile when running from IntelliJ?

I have 5 environments: - local (my development machine) - dev - qc - uat - live - staging I want different application properties to be used for each environment, so I have the following properties files each which have a different URL for…
dleerob
  • 4,951
  • 4
  • 24
  • 36
285
votes
29 answers

How can I add a filter class in Spring Boot?

Is there any annotation for a Filter class (for web applications) in Spring Boot? Perhaps @Filter? I want to add a custom filter in my project. The Spring Boot Reference Guide mentioned about FilterRegistrationBean, but I am not sure how to use it.
janetsmith
  • 8,562
  • 11
  • 58
  • 76
283
votes
15 answers

Override default Spring-Boot application.properties settings in Junit Test

I have a Spring-Boot application where the default properties are set in an application.properties file in the classpath (src/main/resources/application.properties). I would like to override some default settings in my JUnit test with properties…
FrVaBe
  • 47,963
  • 16
  • 124
  • 157
1
2 3
99 100