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
202
votes
28 answers

Read file from resources folder in Spring Boot

I'm using Spring Boot and json-schema-validator. I'm trying to read a file called jsonschema.json from the resources folder. I've tried a few different ways but I can't get it to work. This is my code. ClassLoader classLoader =…
g3blv
  • 3,877
  • 7
  • 38
  • 51
199
votes
11 answers

Spring Boot REST service exception handling

I am trying to set up a large-scale REST services server. We're using Spring Boot 1.2.1 Spring 4.1.5, and Java 8. Our controllers are implementing @RestController and the standard @RequestMapping annotations. My problem is that Spring Boot sets up…
ogradyjd
  • 3,971
  • 6
  • 23
  • 30
198
votes
16 answers

Classpath resource not found when running as jar

Having this problem both in Spring Boot 1.1.5 and 1.1.6 - I'm loading a classpath resource using an @Value annotation, which works just fine when I run the application from within STS (3.6.0, Windows). However, when I run a mvn package and then try…
gyoder
  • 4,530
  • 5
  • 29
  • 37
190
votes
11 answers

What is username and password when starting Spring Boot with Tomcat?

When I deploy my Spring application via Spring Boot and access localhost:8080 I have to authenticate, but what is the username and password or how can I set it? I tried to add this to my tomcat-users file but it didn't work:
Gustavo
  • 3,461
  • 7
  • 26
  • 41
189
votes
13 answers

Disable all Database related auto configuration in Spring Boot

I am using Spring Boot to develop two applications, one serves as the server and other one is a client app. However, both of them are the same app that function differently based on the active profile. I am using auto configuration feature of Spring…
yuva
  • 3,108
  • 4
  • 20
  • 35
188
votes
20 answers

How to set base url for rest in spring boot?

I'm trying to to mix mvc and rest in a single spring boot project. I want to set base path for all rest controllers (eg. example.com/api) in a single place (I don't want annotate each controller with @RequestMapping('api/products'), instead, just…
Teimuraz
  • 8,795
  • 5
  • 35
  • 62
187
votes
8 answers

Could not autowire field:RestTemplate in Spring boot application

I am getting below exception while running Spring Boot application during start up: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'testController': Injection of autowired dependencies failed; nested…
Khuzi
  • 2,792
  • 3
  • 15
  • 26
185
votes
19 answers

Spring Boot Remove Whitelabel Error Page

I'm trying to remove white label error page, so what I've done was created a controller mapping for "/error", @RestController public class IndexController { @RequestMapping(value = "/error") public String error() { return "Error…
Yasitha Waduge
  • 13,180
  • 5
  • 35
  • 42
184
votes
28 answers

Spring Boot: Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean

I am totally new to Spring and started to do the official guides from this site: https://spring.io/guides I'd like to do this guide: https://spring.io/guides/gs/scheduling-tasks/ I get the following Exception: 2014-02-14 16:25:21.614 INFO 9032 ---…
Kumite
  • 2,129
  • 3
  • 15
  • 15
183
votes
23 answers

java.lang.NoClassDefFoundError: Could not initialize class org.codehaus.groovy.vmplugin.v7.Java7

I am getting this exception java.lang.NoClassDefFoundError: Could not initialize class org.codehaus.groovy.vmplugin.v7.Java7 and java.lang.NoClassDefFoundError: Could not initialize class org.codehaus.groovy.reflection.ReflectionCache) when i run…
user3365200
  • 1,981
  • 2
  • 13
  • 13
181
votes
4 answers

Difference between Interceptor and Filter in Spring MVC

I'm a little bit confused about Filter and Interceptor purposes. As I understood from docs, Interceptor is run between requests. On the other hand Filter is run before rendering view, but after Controller rendered response. So where is the…
rpieniazek
  • 2,160
  • 2
  • 12
  • 16
181
votes
4 answers

Does application.yml support environment variables?

I tried using env variables in my application.yml configration like: spring: main: show_banner: false --- spring: profiles: production server: address: $OPENSHIFT_DIY_IP port: $OPENSHIFT_DIY_PORT but the env variables are not…
Marcel Overdijk
  • 11,041
  • 17
  • 71
  • 110
175
votes
11 answers

Speed up Spring Boot startup time

I have a Spring Boot application. I've added a lot of dependencies (unfortunately, looks I need all of them) and the startup time went up quite a lot. Just doing a SpringApplication.run(source, args) takes 10 seconds. While that might not be much…
steady rain
  • 2,246
  • 3
  • 14
  • 18
174
votes
30 answers

ApplicationContextException: Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean

I have written a spring batch application using Spring boot. When I am trying to run that application using command line and classpath on my local system it is running fine. However, when I tried to run it on linux server it is giving me following…
Vijayant Bhatia
  • 2,177
  • 3
  • 10
  • 9
174
votes
13 answers

Spring Boot and multiple external configuration files

I have multiple property files that I want to load from classpath. There is one default set under /src/main/resources which is part of myapp.jar. My springcontext expects files to be on the classpath. i.e.
nir
  • 3,743
  • 4
  • 39
  • 63