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

Stop Jackson from changing case of variable names

I am using Jackson in Spring to serialize my class to JSON. When I serialize a class like the example below, Jackson is changing the names of certain fields from Camel Case to lower case. I know I can work around this by creating custom…
AnthonyW
  • 1,910
  • 5
  • 25
  • 46
20
votes
3 answers

When do we use a SpringApplicationBuilder?

I'm going through a Spring Microservices tutorial and it has the following line in it: new SpringApplicationBuilder(ZuulApplication.class).web(true).run(args); Most of the time I see this to startup a Spring Boot…
Ole
  • 41,793
  • 59
  • 191
  • 359
20
votes
11 answers

H2 not creating/updating table in my Spring Boot app. Something's wrong with my Entity?

I want to keep some data in H2 database by making a CRUD repository, using Hibernate. I can't get the database to store my entries whatsoever. Currently, I'm trying to achieve that during updating the db by making a sample entry. Entry is looking…
VapeKop
  • 349
  • 2
  • 4
  • 13
20
votes
6 answers

Configure spring boot to redirect 404 to a single page app

I want to configure my Spring Boot app to redirect any 404 not found request to my single page app. For example if I am calling localhost:8080/asdasd/asdasdasd/asdasd which is does not exist, it should redirect to localhost:8080/notFound. The…
Vololodymyr
  • 1,996
  • 5
  • 26
  • 45
20
votes
4 answers

Spring boot - Cannot turn off logging

I am trying to turn off the console output in STS for a spring boot application using the application.properties file. Setting the value logging.level.root does seem to have some effect but I can never turn it off completely and nor can I turn off…
berimbolo
  • 3,319
  • 8
  • 43
  • 78
20
votes
3 answers

How do I import configuration classes in a @DataJpaTest in a SpringBootTest?

I have a SpringBoot Application and I a config package with @Configuration @EnableJpaAuditing public class PersistenceConfig { } But the PersistenceConfig does not get picked up in a PersonRepositoryTest @RunWith( SpringRunner.class…
Dachstein
  • 3,994
  • 6
  • 34
  • 61
20
votes
4 answers

Javax @NotNull annotation usage

I have a simple method to get a list of documents for a given companyId. Here is the method: @Override public List getDocumentList(@NotNull Integer companyId) { Company company = new Company(companyId); return…
sisanared
  • 4,175
  • 2
  • 27
  • 42
20
votes
2 answers

How to debug a Java maven spring-boot app in vs code?

I was able to debug a simple Java hello world. The first step was to "compile" with javac -g. I looked up how I would acomplish the same with maven and found http://docs.spring.io/spring-boot/docs/current/maven-plugin/examples/run-debug.html, but…
Rodrigo5244
  • 5,145
  • 2
  • 25
  • 36
20
votes
2 answers

Clean code - Where should @Autowired be applied?

I'll start with a simple example. You have a Spring boot application that runs a CommandLineRunner class on initialization. // MyCommandLineRunner.java public class MyCommandLineRunner implements CommandLineRunner { private final Log logger =…
Toza
  • 1,348
  • 2
  • 14
  • 35
20
votes
3 answers

Spring Boot test - overriding bootstrap.properties

We are using bootstrap.properties in a Spring Boot app to configure Spring Cloud Config related properties. We want to ignore these properties during the testing as we don't want to connect to config server for unit testing. So we are looking for a…
singularity
  • 1,057
  • 2
  • 10
  • 20
20
votes
3 answers

Use @WithMockUser (with @SpringBootTest) inside an oAuth2 Resource Server Application

Environment: I have a spring boot based microservice architecture application consisting of multiple infrastructural services and resource services (containing the business logic). Authorization and authentication is handled by an oAuth2-Service…
David
  • 260
  • 1
  • 5
  • 13
20
votes
2 answers

Default Cache Manager with Spring Boot using @EnableCaching

I have implemented caching in my SpringBootApplication as shown below @SpringBootApplication @EnableCaching public class SampleApplication extends SpringBootServletInitializer { @Override protected SpringApplicationBuilder…
PRATHAP S
  • 675
  • 2
  • 8
  • 26
20
votes
5 answers

"cannot find symbol" error in maven

I see a lot of questions on stackoverflow on this. But still I'm not able to know what is the issue in my way of building projects. I've two spring boot projects: we-data and we-web. we-web is dependent on we-data. we-data compiles fine on maven.…
User1230321
  • 1,435
  • 4
  • 23
  • 39
20
votes
1 answer

multiple Rabbitmq queues with spring boot

From spring boot tutorial: https://spring.io/guides/gs/messaging-rabbitmq/ They give an example of creating 1 queue and 1 queue only, but, what if I want to be able to create more then 1 queue? how would it be possible? Obviously, I can't just…
winter
  • 2,687
  • 4
  • 18
  • 27
20
votes
3 answers

SpringBoot application stuck at springboot logo

I have spring boot application integrated with jersey framework. Now when I try to run that application it just stucks at Spring boot logo and nothing happens after that. I tried adding -X also , but no logs appear after logo.I tried many changes to…
anand
  • 11,071
  • 28
  • 101
  • 159