150,623 questions
1118
votes
65
answers
1.2m
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.
591
votes
31
answers
1.1m
views
How to access a value defined in the application.properties file in Spring Boot
How can I access values provided in application.properties, like
logging.level.org.springframework.web: DEBUG
logging.level.org.hibernate: ERROR
logging.file=${HOME}/application.log
userBucket.path=${...
555
votes
25
answers
745k
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....
512
votes
18
answers
1.1m
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 ...
460
votes
20
answers
555k
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 ...
458
votes
6
answers
264k
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?
396
votes
17
answers
492k
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 ...
392
votes
56
answers
1.4m
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?
******...
391
votes
9
answers
192k
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.
384
votes
40
answers
796k
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 ...
361
votes
11
answers
623k
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 = [...
351
votes
17
answers
706k
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-...
337
votes
20
answers
637k
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 ...
332
votes
4
answers
340k
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 ...
315
votes
22
answers
538k
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 ...