--------------
a
pplication.properties ------------------
Properties files are used to keep ‘N’ number of properties in a single file to run the application in a different environment. In Spring Boot, properties are kept in the application.properties file under the classpath.
a
pplication.properties is very important file to override default values of spring boot.
a
pplication.properties is case sensitive and must be accurate.
YAML File
Spring Boot supports YAML based properties configurations to run the application. Instead of application.properties, we can use application.yml file. This YAML file also should be kept inside the classpath. The sample application.yml file is given below −
spring: application: name: demoservice server: port: 9090
Externalized Properties
Instead of keeping the properties file under classpath, we can keep the properties in different location or path. While running the JAR file, we can specify the properties file path. You can use the following command to specify the location of properties file while running the JAR −
What is Class SpringApplicationBuilder
In our application we have used SpringApplicationBuilder
in the starter
application. starter
is an simple application which will start the actual application instances programatically.
The number of processes to be started and type of process web/standalone will be passed as an argument to starter
application, based on the arguments the application instances will be started. we have used -w
to start as web application for state management.
boolean isWeb = // options parser, parse -w
new SpringApplicationBuilder(SpringBootAngularApp.class).web(isWeb).run(args);
There is another way of doing the same
SpringApplication sp = new SpringApplication(SpringApplicationBuilder.class);
sp.setWebEnvironment(false);
sp.run(args);
We can also customise banner, loggers with SpringApplicationBuilder
.
No comments:
Post a Comment