There are a few ways to prevent Spring Boot from loading the default application.properties
file or other configuration files. Here are some options:
spring.config.name
and spring.config.location
properties. For example, you can run your application with the following command line options to specify a different configuration file:java -jar myapp.jar --spring.config.name=myapp --spring.config.location=/path/to/config/
This tells Spring Boot to look for a file called myapp.properties
or myapp.yml
in the /path/to/config/
directory.
spring.autoconfigure.exclude
property to a comma-separated list of auto-configuration classes to exclude. For example, to disable all auto-configuration, you can add the following to your application.properties
file:spring.autoconfigure.exclude=*
application.properties
. Spring Boot automatically maps system properties and environment variables to properties in your application. For example, you can set the server.port
property using an environment variable called SERVER_PORT
:export SERVER_PORT=8080
spring.profiles.active
property. For example, you can define a development
profile in a file called application-development.properties
and activate it using the following command line option:java -jar myapp.jar --spring.profiles.active=development
This tells Spring Boot to load properties from the application-development.properties
file instead of the default application.properties
.
Asked: 2022-12-11 11:00:00 +0000
Seen: 8 times
Last updated: Jun 28 '21