• Register
100 points
‚óŹ3

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.

Spring Boot provides various properties that can be configured in the application.properties file. The properties have default values. We can set a property(s) for the Spring Boot application. Spring Boot also allows us to define our own property if required.

The application.properties file allows us to run an application in a different environment. In short, we can use the application.properties file to:

  • Configure the Spring Boot framework
  • define our application custom configuration properties
 
Spring Boot application.properties example file
 
#configuring application name  
spring.application.name = demoApplication  
#configuring port  
server.port = 8081  

In the above example, we have configured the application name and port. The port 8081 denotes that the application runs on port 8081.

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

 

More Posts

Create a Web application in Spring boot with PostgreSQL (Part-3) darshan1507 - May 25
REST APIs / Services with Spring boot darshan1507 - Jun 5
Error occurred during initialization of boot layer. Hasnain_khan - Oct 12, 2020
Uploading files to AWS S3 Bucket using Spring Boot darshan1507 - Jun 7
Spring framework annotations @Autowire @Component @Bean @Configuration @Value darshan1507 - Jun 5
Spring AOP Interview Questions Lalit Kumar - Dec 30, 2020
Create a Web application in Spring boot with PostgreSQL (Part-2) darshan1507 - May 25
Create a Web application in Spring boot with PostgreSQL (Part-1) darshan1507 - May 25
Write an application that finds the smallest of several integers offonime - May 23
How to make a set in Java sakshi - Jun 5