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
19
votes
3 answers

Spring boot multiple data sources using EntityManager

I'm trying to setup a Springboot (v2.0.0.BUILD-SNAPSHOT) project with multiple datasources using this tutorial from INFOQ https://www.infoq.com/articles/Multiple-Databases-with-Spring-Boot But instead of JdbcTemplate i need to use multiple…
Bruno
  • 543
  • 2
  • 7
  • 21
19
votes
5 answers

Spring boot external configuration of property file

I have a spring boot application that I can package in a war that I want to deploy to different environments. To automate this deployment it'd be easier to have the configuration file externalized. Currently everything works fine with a…
turoni
  • 1,345
  • 1
  • 18
  • 37
19
votes
6 answers

Return custom object from Spring Data with Native Query

My question is based on another post. How can I achieve the same with a native query? Native queries do not allow JPQL thus do not allow new instances either. My POJO. class Coordinates { private final BigDecimal latitude private final…
Sidney de Moraes
  • 993
  • 3
  • 11
  • 29
19
votes
2 answers

How to use JPA Query to insert data into db?

I have a problem with my prepared statement but i can not figure out where the error is. I am trying to insert a URI link into the database. @Repository public interface LoggerDao extends CrudRepository { @Query("select t from…
Arthur Decker
  • 1,191
  • 3
  • 15
  • 45
19
votes
4 answers

Spring Boot: Wrapping JSON response in dynamic parent objects

I have a REST API specification that talks with back-end microservices, which return the following values: On "collections" responses (e.g. GET /users) : { users: [ { ... // single user object data } ], links:…
filpa
  • 3,651
  • 8
  • 52
  • 91
19
votes
3 answers

Spring mvc : Changing default Response format from xml to json

I have gone through other similar asked questions but nothing worked for me. All my API's return JSON as response by Default: Because of some XML API, i had to add jackson-xml
lesnar
  • 2,400
  • 7
  • 41
  • 72
19
votes
7 answers

Disable @Schedule on Spring Boot IntegrationTest

How can I disable the schedule auto-start on Spring Boot IntegrationTest? Thanks.
fassoline
  • 191
  • 1
  • 1
  • 6
19
votes
7 answers

Jackson is ignoring spring.jackson.properties in my spring boot application

Jackson is ignoring spring.jackson.property-naming-strategy=SNAKE_CASE. I am using springBootVersion 1.4.2.RELEASE. In my application.properties file, I have added spring.jackson.property-naming-strategy=SNAKE_CASE But Jackson is not honoring…
so-random-dude
  • 15,277
  • 10
  • 68
  • 113
19
votes
1 answer

springboot : how to return error status code in prehandle of HandlerInterceptor

I am using HandlerInterceptor in Spring Boot for processing common types of requests. But while executing preHandle, I want to return error status code to user if conditions are not met. If i throw the exception inside preHandle the response will…
santosh kumar
  • 1,465
  • 3
  • 13
  • 14
19
votes
2 answers

application.properties outside jar file how to

As stated in spring-boot-reference: On your application classpath (e.g. inside your jar) you can have an application.properties that provides a sensible default property value for name. When running in a new environment, an…
Gibi
  • 451
  • 1
  • 3
  • 12
19
votes
1 answer

How to replace deprecated MultipleHiLoPerTableGenerator with TableGenerator in Hibernate

I use hibernate in an application with spring boot 1.4.0.RELEASE. The Entity for the index looks something along the lines of: @Entity(name = "SearchableTariffItem") @Indexed public class SearchableTariffItem { public static final String…
leo
  • 3,677
  • 7
  • 34
  • 46
19
votes
7 answers

how to run/turn off selective tests based on profiles in spring boot

I have a spring-boot application for which I am writing IT tests. The data for the tests comes from application-dev.properties when I activate dev profile Here is what I have for…
brain storm
  • 30,124
  • 69
  • 225
  • 393
19
votes
11 answers

Unit testing of Spring Boot Actuator endpoints not working when specifying a port

recently I changed my spring boot properties to define a management port. In doing so, my unit tests started to fail :( I wrote a unit test that tested the /metrics endpoint as follows: @RunWith…
WHGIBBO
  • 199
  • 1
  • 2
  • 7
19
votes
4 answers

Issue with testing Spring MVC slice in SpringBoot 1.4

I'm trying out the new Spring Boot 1.4 MVC testing features. I have the following controller. @Controller public class ProductController { private ProductService productService; @Autowired public void setProductService(ProductService…
user2693135
  • 1,206
  • 5
  • 21
  • 44
19
votes
4 answers

Springboot not loading application.dev.properties file

In my project I want to use environment specific property file. For example if I am running it into development it should use application.dev.properties, for production it should use application.prod.properties and so on. I have below two files in…
Sam
  • 2,972
  • 6
  • 34
  • 62
1 2 3
99
100