Skip to main content

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
Filter by
Sorted by
Tagged with
1077 votes
65 answers
1.1m views

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's user avatar
  • 62.5k
572 votes
31 answers
1.1m views

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=...
Qasim's user avatar
  • 9,468
539 votes
25 answers
693k views

How can I log SQL statements in Spring Boot?

I want to log SQL statements to a file. I have the following properties in application.properties: spring.datasource.url=... spring.datasource.username=user spring.datasource.password=1234 spring....
Oleg Pavliv's user avatar
490 votes
18 answers
929k views

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 ...
zeodtr's user avatar
  • 11.1k
444 votes
6 answers
239k views

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's user avatar
441 votes
20 answers
510k views

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 ...
stewsters's user avatar
  • 4,585
380 votes
9 answers
180k views

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's user avatar
  • 5,074
372 votes
40 answers
763k views

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 ...
Kleber Mota's user avatar
  • 8,795
363 votes
53 answers
1.2m views

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? ******...
Jeff Cook's user avatar
  • 8,646
342 votes
10 answers
569k views

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 = [...
juventus's user avatar
  • 3,432
329 votes
17 answers
630k views

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-...
Vinod's user avatar
  • 3,977
319 votes
19 answers
534k views

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 ...
dleerob's user avatar
  • 5,241
309 votes
22 answers
508k views

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 ...
Lithicas's user avatar
  • 3,953
308 votes
4 answers
298k views

What is this spring.jpa.open-in-view=true property in Spring Boot?

I saw spring.jpa.open-in-view=true property in Spring Boot documentation for JPA configuration. Is the true default value for this property if it's not provided at all?; What does this really do? I ...
Carlos Alberto's user avatar
297 votes
15 answers
434k views

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 ...
FrVaBe's user avatar
  • 49k
288 votes
29 answers
431k views

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 ...
janetsmith's user avatar
  • 8,682
285 votes
34 answers
620k views

Spring boot - Not a managed type

I use Spring boot+JPA and having a problem while starting the service. Caused by: java.lang.IllegalArgumentException: Not an managed type: class com.nervytech.dialer.domain.PhoneSettings at org....
user1578872's user avatar
  • 8,788
281 votes
24 answers
323k views

Why does my Spring Boot App always shutdown immediately after starting?

This is my first Spring Boot code. Unfortunately, it always shuts down. I was expecting it to run continuously so that my web client can get some data from the browser. package hello; import org....
johnsam's user avatar
  • 4,472
281 votes
11 answers
236k views

Difference between Spring MVC and Spring Boot [closed]

I have just started learning Spring. In my next step, I would like to develop bigger web applications. Now I am wondering if I should start with Spring Boot or Spring MVC. I have already read some ...
Gero's user avatar
  • 13.3k
272 votes
4 answers
165k views

Difference between @Mock, @MockBean and Mockito.mock()

When creating tests and mocking dependencies, what is the difference between these three approaches? @MockBean: @MockBean MyService myservice; @Mock: @Mock MyService myservice; Mockito.mock() ...
Doug's user avatar
  • 6,199
263 votes
10 answers
239k views

Compilation error after upgrading to JDK 21 - "NoSuchFieldError: JCImport does not have member field JCTree qualid"

After upgrading to JDK 21, I have the following compilation error in my Spring Boot project: Fatal error compiling: java.lang.NoSuchFieldError: Class com.sun.tools.javac.tree.JCTree$JCImport does not ...
Honza Zidek's user avatar
  • 16.9k
262 votes
11 answers
354k views

Spring Boot YAML configuration for a list of strings

I am trying to load an array of strings from the application.yml file. This is the config: ignore: filenames: - .DS_Store - .hg This is the class fragment: @Value("${ignore....
Bahadır Yağan's user avatar
246 votes
55 answers
926k views

Consider defining a bean of type 'package' in your configuration [Spring-Boot]

I am getting the following error: *************************** APPLICATION FAILED TO START *************************** Description: Parameter 0 of method setApplicant in webService.controller....
Mike3355's user avatar
  • 11.8k
238 votes
22 answers
519k views

Add context path to Spring Boot application

I am trying to set a Spring Boot applications context root programmatically. The reason for the context root is we want the app to be accessed from localhost:port/{app_name} and have all the ...
CorreyS's user avatar
  • 2,543
238 votes
36 answers
607k views

Spring Boot - Cannot determine embedded database driver class for database type NONE

This is the error that is thrown when trying to run my web app: [INFO] WARNING: Nested in org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework....
quarks's user avatar
  • 34.6k
238 votes
16 answers
293k views

Unable to find a @SpringBootConfiguration when doing a JpaTest

I'm trying to run a simple Junit test to see if my CrudRepositories are indeed working. The error I keep getting is: Unable to find a @SpringBootConfiguration, you need to use @ContextConfiguration ...
Thomas Billet's user avatar
228 votes
28 answers
615k views

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....
g3blv's user avatar
  • 4,237
224 votes
7 answers
506k views

How do I retrieve query parameters in a Spring Boot controller?

I am developing a project using Spring Boot. I've a controller which accepts GET requests. Currently I'm accepting requests to the following kind of URLs: http://localhost:8888/user/data/002 but ...
Mehandi Hassan's user avatar
222 votes
28 answers
279k views

Spring Boot not serving static content

I can't get my Spring-boot project to serve static content. I've placed a folder named static under src/main/resources. Inside it I have a folder named images. When I package the app and run it, it ...
Vinicius Carvalho's user avatar
221 votes
3 answers
101k views

Spring Boot - parent pom when you already have a parent pom

Is there a specific recommended approach to the inclusion of the spring-boot parent pom into projects that already have a required parent POM? What do you recommend for projects that need to extend ...
Scott C.'s user avatar
  • 3,812
216 votes
20 answers
171k views

Spring Boot application as a Service

How to configure nicely Spring Boot application packaged as executable jar as a Service in the Linux system? Is this recommended approach, or should I convert this app to war and install it into ...
MariuszS's user avatar
  • 31.3k
215 votes
11 answers
236k views

How do I tell Spring Boot which main class to use for the executable jar?

Execution default of goal org.springframework.boot:spring-boot-maven-plugin:1.0.1.RELEASE:repackage failed: Unable to find a single main class from the following candidates My project has more ...
Thilo's user avatar
  • 261k
208 votes
17 answers
276k views

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)....
gyoder's user avatar
  • 4,680
203 votes
12 answers
293k views

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....
yuva's user avatar
  • 3,258
201 votes
11 answers
364k views

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 ...
astrien's user avatar
  • 3,991
199 votes
11 answers
340k views

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 ...
Gustavo's user avatar
  • 3,661
198 votes
25 answers
382k views

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....
user3365200's user avatar
  • 2,141
197 votes
20 answers
366k views

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 @...
Teimuraz's user avatar
  • 9,175
195 votes
4 answers
199k views

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 ...
rpieniazek's user avatar
  • 2,310
194 votes
30 answers
461k views

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 ...
Vijayant Bhatia's user avatar
193 votes
19 answers
453k views

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") ...
Yasitha Waduge's user avatar
193 votes
8 answers
270k views

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 ...
Khuzi's user avatar
  • 2,852
189 votes
4 answers
215k views

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: $...
Marcel Overdijk's user avatar
185 votes
28 answers
421k views

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 ...
Kumite's user avatar
  • 2,149
183 votes
1 answer
193k views

How to determine programmatically the current active profile using Spring boot [duplicate]

Is there a way programmatically to get the current active profile within my bean?
rayman's user avatar
  • 21.4k
182 votes
14 answers
244k views

Spring Boot + JPA : Column name annotation ignored

I have a Spring Boot application with dependency spring-boot-starter-data-jpa. My entity class has a column annotation with a column name. For example: @Column(name="TestName") private ...
Kamil's user avatar
  • 2,258
181 votes
11 answers
165k views

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) ...
steady rain's user avatar
  • 2,306
179 votes
29 answers
434k views

Spring Boot: Cannot access REST Controller on localhost (404)

I am trying to adapt the REST Controller example on the Spring Boot website. Unfortunately I've got the following error when I am trying to access the localhost:8080/item URL. { "timestamp": ...
mchlfchr's user avatar
  • 4,188
176 votes
13 answers
679k views

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. ...
nir's user avatar
  • 3,820
176 votes
12 answers
278k views

Java Spring Boot: How to map my app root (“/”) to index.html?

How can I map my app root http://localhost:8080/ to a static index.html? If I navigate to http://localhost:8080/index.html its works fine. My app structure is : My config\WebConfig.java looks like ...
Shoham's user avatar
  • 7,234

1
2 3 4 5
2990