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
143
votes
21 answers

Why am I getting Unknown error in line 1 of pom.xml?

Getting unknown error at Line 1 in pom.xml in Eclipse IDE. It was working fine till yesterday, but all of a sudden after updating my project from master and after fixing merge conflicts getting "Unknown error" in pom.xml. Except me, none of my…
Shravani
  • 1,622
  • 2
  • 11
  • 16
142
votes
18 answers

How to resolve Unable to load authentication plugin 'caching_sha2_password' issue

In eclipse when i started my application i got this - Could not discover the dialect to use. java.sql.SQLException: Unable to load authentication plugin 'caching_sha2_password'. at java.sql.SQLException: Unable to load authentication plugin …
Sarath Mohan
  • 1,338
  • 2
  • 10
  • 10
142
votes
10 answers

Returning JSON object as response in Spring Boot

I have a sample RestController in Spring Boot: @RestController @RequestMapping("/api") class MyRestController { @GetMapping(path = "/hello") public JSONObject sayHello() { return new JSONObject("{'aa':'bb'}"); } } I am using…
iwekesi
  • 2,228
  • 4
  • 19
  • 29
142
votes
2 answers

Difference between using MockMvc with SpringBootTest and Using WebMvcTest

I am new to Spring Boot and am trying to understand how testing works in SpringBoot. I am a bit confused about what is the difference between the following two code snippets: Code snippet…
Revansha
  • 1,923
  • 4
  • 16
  • 21
140
votes
16 answers

How to use LocalDateTime RequestParam in Spring? I get "Failed to convert String to LocalDateTime"

I use Spring Boot and included jackson-datatype-jsr310 with Maven: com.fasterxml.jackson.datatype jackson-datatype-jsr310 2.7.3 When I try to use…
Kery Hu
  • 5,626
  • 11
  • 34
  • 51
138
votes
12 answers

How to debug spring-boot application with IntelliJ IDEA community Edition?

I'm having difficulties in debugging a Java spring-boot application on IntelliJ IDEA community Edition. The main problem is, that the IDE won't stop on a breakpoint, even the program surely executes through it. How can I make the the IntelliJ IDEA…
Ville Miekk-oja
  • 18,749
  • 32
  • 70
  • 106
137
votes
24 answers

Plugin 'org.springframework.boot:spring-boot-maven-plugin:' not found

I'm facing an error in my pom.xml file given below: Plugin 'org.springframework.boot:spring-boot-maven-plugin:' not found Below is my pom.xml :
Lakma Chehani
  • 1,415
  • 2
  • 6
  • 5
137
votes
2 answers

Spring injects dependencies in constructor without @Autowired annotation

I'm experimenting with examples from this official Spring tutorials and there is a dependency on this code: https://github.com/spring-guides/gs-async-method/tree/master/complete If you look at the code on AppRunner.java class, I have 2…
winter
  • 2,687
  • 4
  • 18
  • 27
136
votes
33 answers

Unable to get spring boot to automatically create database schema

I'm unable to get spring boot to automatically load my database schema when I start it up. Here is my…
napentathol
  • 1,583
  • 2
  • 13
  • 15
135
votes
15 answers

@ConfigurationProperties Spring Boot Configuration Annotation Processor not found in classpath

I try to make completion for custom properties in Spring Boot. I tried to create a simple project via IntelliJ IDEA 2016.3: Created a new Gradle project with Spring Boot Initializer (I haven't checked anything at all). Created a new class…
Boris
  • 4,944
  • 7
  • 36
  • 69
133
votes
13 answers

Spring Boot - How to get the running port

I have a spring boot application (using embedded tomcat 7), and I've set server.port = 0 in my application.properties so I can have a random port. After the server is booted up and running on a port, I need to be able to get the port that that was…
Tucker
  • 7,017
  • 9
  • 37
  • 55
132
votes
5 answers

Cannot be cast to class - they are in unnamed module of loader 'app'

I'm trying to create a bean from sources that were generated by wsdl2java. Every time I try to run my Spring Boot app, I get the following error: Caused by: java.lang.ClassCastException: class org.apache.cxf.endpoint.ClientImpl cannot be cast to…
Cisco
  • 20,972
  • 5
  • 38
  • 60
131
votes
24 answers

How to configure CORS in a Spring Boot + Spring Security application?

I use Spring Boot with Spring Security and Cors Support. If I execute following code url = 'http://localhost:5000/api/token' xmlhttp = new XMLHttpRequest xmlhttp.onreadystatechange = -> if xmlhttp.readyState is 4 console.log…
Rudolf Schmidt
  • 2,345
  • 5
  • 21
  • 28
130
votes
8 answers

Spring Boot - inject map from application.yml

I have a Spring Boot application with the following application.yml - taken basically from here: info: build: artifact: ${project.artifactId} name: ${project.name} description: ${project.description} version:…
levant pied
  • 3,886
  • 5
  • 37
  • 56
129
votes
13 answers

How to use Spring Boot profiles?

I have the application.yml, application-dev.yml and application-dev.yml files I'm using the maven command mvn spring-boot:run -Dspring.profiles.active=dev it doesn't work and I can not choose the dev profile using mvn spring-boot:run. How do I…
twogoods
  • 1,646
  • 2
  • 14
  • 21