Recommended Case for Spring Properties | Generated by AI

Home 2026.01

Question: What case should we use in Spring properties?

Answer:

In Spring Boot (and Spring Framework in general), the recommended and most commonly used case for properties keys (in application.properties, application.yml, environment variables, etc.) in 2025–2026 is:

kebab-case (lowercase with hyphens)

# This is the Spring Boot team recommended style
server.port=8080
spring.datasource.url=jdbc:...
management.endpoints.web.exposure.include=health,info,prometheus
logging.level.org.springframework.web=DEBUG
spring.jpa.hibernate.ddl-auto=none

Official & community conventions in 2025–2026

Style Example Status in Spring Boot When you still see it
kebab-case spring.datasource.url Recommended • Official default Everywhere in docs, starters, examples
camelCase spring.datasource.url Supported, but not preferred Old code, people coming from Java-land
snake_case spring_datasource_url Supported (mostly env vars) Kubernetes ConfigMaps, some Helm charts
UPPER_CASE SPRING_DATASOURCE_URL Supported (environment variables) Docker, Kubernetes, CI/CD, 12-factor apps

Quick rules most teams follow today

// Recommended
@ConfigurationProperties(prefix = "feature-toggle")
public class FeatureToggleProperties {  }

// Still works, but less common now
@ConfigurationProperties(prefix = "featureToggle")

YAML is even stricter — kebab-case is basically mandatory for readability

spring:
  datasource:
    url: jdbc:postgresql://...
    username: app_user
    hikari:
      maximum-pool-size: 15
management:
  endpoints:
    web:
      exposure:
        include: health,metrics,prometheus

Summary – what to use in new code (2026 best practice)

Almost every new Spring Boot project started in 2024–2026 follows kebab-case for properties.

References:


Back

x-ai/grok-4.1-fast

Donate