← Back to Questions
Spring Boot

What is application.properties in Spring Boot?

Learn What is application.properties in Spring Boot? with simple explanations, real-time examples, interview tips and practical use cases.

What is application.properties in Spring Boot?

The application.properties file in Spring Boot is the main configuration file used to define application settings, environment configurations, and framework properties.

It allows developers to externalize configuration instead of hardcoding values inside Java classes.

In simple terms:

  • application.properties stores configuration values
  • Spring Boot automatically reads this file during startup
  • It controls application behavior
  • It supports environment-specific configurations

The application.properties file is heavily used in:

  • Spring Framework
  • Spring Boot
  • Microservices Architecture
  • Cloud-Native Systems
  • Enterprise Applications

Simple Definition

application.properties is a Spring Boot configuration file used to store application settings and environment-specific properties.


Why application.properties is Important

Enterprise applications require:

  • Dynamic configuration
  • Environment flexibility
  • Secure configuration management
  • Easy deployment changes

Hardcoding values inside Java classes creates problems:

  • Poor maintainability
  • Difficult deployment management
  • Security risks
  • Environment dependency issues

The application.properties file solves these problems.


Real-Time Banking Example

Consider a banking application requiring:

  • Database URL
  • JWT secret key
  • Email server configuration
  • Payment gateway API keys
  • Microservice URLs

Instead of hardcoding:

private String databaseUrl =
"jdbc:mysql://localhost:3306/bank_db";
    

Developers store configurations in:

application.properties
    

How application.properties Works Internally

Application Starts
      |
Spring Boot Searches Configuration Files
      |
application.properties Loaded
      |
Properties Parsed
      |
Values Injected into Beans
      |
Application Ready
    

Default Location of application.properties

Spring Boot automatically searches for:

src/main/resources/application.properties
    

Basic application.properties Example

spring.application.name=banking-app

server.port=9090
    

Accessing Properties Using @Value

application.properties

app.name=Dhanish Empower
    

Java Class

@Value("${app.name}")
private String appName;
    

Spring injects:

Dhanish Empower
    

Common Properties in Spring Boot

  • Server configuration
  • Database configuration
  • Logging configuration
  • Security configuration
  • Mail configuration
  • Cache configuration
  • Microservice URLs

Server Configuration Example

server.port=9090

server.servlet.context-path=/api
    

Database Configuration Example

spring.datasource.url=
jdbc:mysql://localhost:3306/bank_db

spring.datasource.username=root

spring.datasource.password=root
    

JPA Configuration Example

spring.jpa.hibernate.ddl-auto=update

spring.jpa.show-sql=true
    

Logging Configuration Example

logging.level.root=INFO

logging.level.com.bank=DEBUG
    

Security Configuration Example

jwt.secret=mySecretKey

jwt.expiration=3600
    

Email Configuration Example

spring.mail.host=smtp.gmail.com

spring.mail.port=587

spring.mail.username=test@gmail.com

spring.mail.password=password
    

Microservices Configuration Example

service.payment.url=
http://localhost:8081

service.notification.url=
http://localhost:8082
    

Using Environment Variables

Spring Boot supports environment variable placeholders.

Example

spring.datasource.url=
${DB_URL}

spring.datasource.username=
${DB_USERNAME}

spring.datasource.password=
${DB_PASSWORD}
    

Using Default Values

Example

server.port=${PORT:9090}
    

If:

PORT
    

is unavailable, Spring uses:

9090
    

Using Profiles with application.properties

Spring Boot supports profile-specific configuration files.

Examples

application-dev.properties

application-test.properties

application-prod.properties
    

Development Profile Example

spring.datasource.url=
jdbc:mysql://localhost:3306/dev_db
    

Production Profile Example

spring.datasource.url=
jdbc:mysql://prod-db:3306/prod_db
    

Activating Profiles

spring.profiles.active=prod
    

Using application.properties with @ConfigurationProperties

application.properties

app.name=Dhanish Empower

app.version=1.0
    

Java Class

@ConfigurationProperties(prefix = "app")
@Component
public class AppConfig {

    private String name;

    private String version;

}
    

application.properties vs application.yml

Feature application.properties application.yml
Format Key-Value YAML Structure
Readability Simple Better for Complex Configurations
Complex Hierarchies Difficult Easy
Popularity Very Common Increasingly Popular

application.yml Example

server:
  port: 9090

spring:
  datasource:
    url: jdbc:mysql://localhost:3306/bank_db
    

Advantages of application.properties

  • Externalized configuration
  • Environment flexibility
  • Easy deployment management
  • Improved maintainability
  • Supports cloud-native architecture

1. Externalized Configuration

Application settings remain outside source code.


2. Environment Flexibility

Different environments can use different configurations.


3. Better Security

Sensitive information such as:

  • Passwords
  • API keys
  • JWT secrets

can be managed securely.


4. Easier Deployment

Configuration changes do not require recompiling the application.


Disadvantages of application.properties

  • Large configurations become difficult to manage
  • Duplicate properties may occur
  • Complex hierarchical configurations are harder

application.properties in Microservices

Modern microservices architectures heavily rely on:

application.properties
    

because:

  • Each service requires separate configuration
  • Cloud deployments are dynamic
  • Containerized applications need flexibility
  • Distributed systems require environment-specific settings

Microservices Banking Example

service.payment.url=
http://payment-service:8081

service.notification.url=
http://notification-service:8082
    
gateway.internal.admin.secret=
mySecret
    

Microservices dynamically communicate using configurable service URLs.


application.properties in Docker

spring.datasource.url=
${DB_URL}

spring.datasource.username=
${DB_USERNAME}
    

Docker environment variables override property values dynamically.


application.properties in Kubernetes

Kubernetes ConfigMaps and Secrets commonly provide values for Spring Boot applications.


Common Spring Annotations Related to application.properties

  • @Value
  • @ConfigurationProperties
  • @PropertySource
  • @Configuration
  • @Bean

Real-World Enterprise Use Cases

  • Database configuration
  • Security management
  • Cloud deployments
  • Microservices communication
  • API integrations

Common Interview Questions

What is application.properties in Spring Boot?

application.properties is the main configuration file used to define Spring Boot application settings and environment configurations.

Where is application.properties located?

It is usually located inside:

src/main/resources
    

What is the difference between application.properties and application.yml?

application.properties uses key-value format, while application.yml uses YAML hierarchical structure.


Professional Interview Answer

The application.properties file in Spring Boot is the primary external configuration file used to define application settings such as server ports, database connections, security properties, logging levels, API configurations, and environment-specific settings. Spring Boot automatically loads this file during startup and injects values into Spring Beans using annotations such as @Value and @ConfigurationProperties. It plays a major role in enterprise and microservices architectures by supporting flexible, secure, and maintainable application configuration management.


Conclusion

The application.properties file is one of the most fundamental and powerful configuration mechanisms in Spring Boot.

It enables externalized configuration management, environment flexibility, secure deployment handling, and scalable enterprise application architecture.

Modern enterprise systems, banking platforms, cloud-native systems, REST APIs, Dockerized applications, and microservices architectures heavily rely on application.properties for dynamic and production-ready application configuration management.

Understanding application.properties is essential for Java developers, Spring Boot developers, backend engineers, DevOps engineers, and software architects preparing for interviews and building enterprise-grade applications.

Why this Spring Boot question is important?

This interview question helps candidates understand real-time backend development concepts, practical problem solving, coding fundamentals, system design basics and production-ready application behavior.

Practice this question carefully for Java backend roles, Spring Boot developer interviews, microservices interviews, company interviews and full-stack developer preparation.

About the Author

Naresh Kumar is a Senior Java Backend Engineer with experience building enterprise applications using Java, Spring Boot, Microservices, Docker, Kubernetes and Cloud technologies.