I was trying to decompile the jar files inside Spring trying to find the default application.properties, am I wrong or it exists something like a mother file that we override.
Thanks in advance!
CodePudding user response:
When using Spring Boot, the usual way to create an executable JAR file is to simply use the provided spring-boot-maven-plugin
(or the Gradle equivalent, spring-boot-gradle-plugin
).
By default, the structure of the JAR when created this way is as follows:
$ ls
my-app-0.0.1-SNAPSHOT.jar
$ unzip my-app-0.0.1-SNAPSHOT.jar
$ ls my-app-0.0.1-SNAPSHOT
./BOOT-INF
./META-INF
./org
The application configuration is, by default, located under ./BOOT-INF/classes
. Any application.properties
(as well as other resources under src/main/resources
) will be located there by default.
If you do not provide an application.properties
, then sensible defaults will be used for many (but not all) components that you may be using (by e.g. including them in your pom.xml
or build.gradle
project file). In this case, no application.properties
file will be present inside the JAR file. For example, if no server.port
property was defined, a default of 8080
will be used to run your application.
There are many ways to configure a Spring Boot application. For the full list, including precedence of each way, see the reference documentation.
CodePudding user response:
There is no default application.properties
(or application.yaml
file) in Spring Boot. Instead, the defaults are defined in code, typically in classes annotated with @ConfigurationProperties
. The properties that Spring Boot itself supports and their default values are listed in the reference documentation.