Open-Source Wikis

/

Spring Framework

/

Reference

/

Configuration

spring-projects/spring-framework

Configuration

Spring Framework configuration spans build-time settings, the Environment abstraction, profiles, and a handful of system properties that change runtime behavior.

Build-time settings

gradle.properties at the repository root configures the Gradle build:

version=7.1.0-SNAPSHOT
org.gradle.caching=true
org.gradle.jvmargs=-Xmx2048m
org.gradle.parallel=true
kotlinVersion=2.3.20
byteBuddyVersion=1.17.6

.sdkmanrc pins the recommended JDK for development:

java=25-librca

Environment and property sources

The Environment (defined in spring-core, spring-core/src/main/java/org/springframework/core/env/Environment.java) is Spring's central abstraction for accessing properties and active profiles.

Default property source order

For StandardEnvironment (non-web):

  1. systemPropertiesSystem.getProperties()
  2. systemEnvironmentSystem.getenv()

For StandardServletEnvironment (Servlet web), additionally:

  1. servletConfigInitParams
  2. servletContextInitParams

For StandardReactiveWebEnvironment (reactive), the standard two sources only.

User-configured property sources (e.g., from @PropertySource or programmatic MutablePropertySources) are inserted at well-known positions.

Profiles

Profiles are activated via:

  • spring.profiles.active system property or environment variable
  • Environment.setActiveProfiles(...) programmatically
  • @ActiveProfiles in tests

Beans annotated @Profile("dev") are registered only when "dev" is active. Profile expressions support boolean operators: @Profile("dev & !cloud").

Placeholders

${property} placeholders in @Value, XML config, or annotation attributes are resolved by PropertySourcesPlaceholderConfigurer. Default-value syntax: ${db.url:jdbc:h2:mem:test}.

System properties of note

Property Effect
spring.profiles.active Comma-separated active profiles
spring.profiles.default Profiles to activate when none are explicit
spring.test.context.cache.maxSize TestContext cache size (default 32)
spel.compiler.mode off, immediate, mixed — SpEL bytecode compilation
org.springframework.aot.enabled Force-enable AOT mode at runtime
org.aspectj.weaver.loadtime.configuration AspectJ load-time weaving configuration file

Logging

Spring Framework uses Apache Commons Logging as a facade. The framework ships spring-jcl (transitively, via spring-core) which discovers Log4j 2 / SLF4J / java.util.logging on the classpath and routes through them.

Key logger names for diagnostics:

Logger What it shows
org.springframework.beans.factory Bean creation
org.springframework.context Context lifecycle
org.springframework.web Web-stack request handling
org.springframework.web.servlet Spring MVC dispatcher
org.springframework.web.reactive WebFlux dispatcher
org.springframework.transaction Transaction management
org.springframework.cache @Cacheable interceptor
org.springframework.aop.framework AOP proxy creation

Set to DEBUG for verbose tracing.

Native image / AOT settings

When building a GraalVM native image:

  • The Spring AOT processing runs at build time and emits source under build/generated/aotSources and resources under build/generated/aotResources.
  • The reachability metadata produced is consumed by native-image to keep reflection, resources, proxies, and serialization reachable.
  • Custom hints registered via RuntimeHintsRegistrar are picked up automatically.

Reference docs (Antora)

The reference documentation source is in framework-docs/modules/ROOT/. To build:

./gradlew antora

Output: framework-docs/build/site/index.html.

See also

Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.

Configuration – Spring Framework wiki | Factory