DEV Community

Hunor Vadasz-Perhat
Hunor Vadasz-Perhat

Posted on

spring-016: application.properties-common-configuration-categories

The application.properties file in Spring Boot serves as a central hub for configuring various aspects of your application. By specifying key-value pairs, you can fine-tune behaviors ranging from server settings to data source configurations. Here's a concise overview:

Common Configuration Categories

  1. Server Configuration

    • Port: Define the HTTP port your application listens on.
      • server.port=8080
    • Context Path: Set the base URI for your application.
      • server.servlet.context-path=/myapp
  2. Logging Configuration

    • Log Level: Adjust the verbosity of logs for specific packages.
      • logging.level.org.springframework=DEBUG
    • Log File: Specify the file to write logs to.
      • logging.file.name=app.log
  3. Data Source Configuration

    • Database URL: Set the JDBC URL for your database.
      • spring.datasource.url=jdbc:mysql://localhost:3306/mydb
    • Credentials: Provide database username and password.
      • spring.datasource.username=root
      • spring.datasource.password=secret
  4. Spring MVC Configuration

    • View Prefix/Suffix: Define the location and file extension for view templates.
      • spring.mvc.view.prefix=/WEB-INF/views/
      • spring.mvc.view.suffix=.jsp
  5. Internationalization (i18n)

    • Locale: Set the default locale for your application.
      • spring.mvc.locale=en_US
    • Message Source: Specify the basename for message properties.
      • spring.messages.basename=messages
  6. Security Configuration

    • Enable Security: Toggle Spring Security for your application.
      • spring.security.enabled=true
    • User Credentials: Define default user details.
      • spring.security.user.name=admin
      • spring.security.user.password=admin
  7. Actuator Endpoints

    • Enable All Endpoints: Expose all actuator endpoints.
      • management.endpoints.web.exposure.include=*
    • Health Endpoint: Customize health check settings.
      • management.endpoint.health.show-details=always
  8. Custom Application Properties

    • Define your own properties for use within the application.
      • app.feature.enabled=true
      • app.service.timeout=5000

Comprehensive Resource

For an exhaustive list of available properties and their descriptions, refer to the official Spring Boot documentation:

Common Application Properties: (docs.spring.io)

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay