PropertySource class

Adds property files to the environment, on top of the application's configuration files.

Use it for a file that belongs to one part of the application (a feature's defaults, a file outside the usual locations), so that its keys are available to @Value and ${...}. The files are read while the bean definitions load, so later conditions and every bean see them; they are read only when the declaring class's conditions (@Profile, @Conditional, ...) match. Locations may contain ${...} placeholders and patterns (file:config/*.properties); when several files define the same key, the last location wins. It reads .properties files; give a factory for another format such as YAML.

// The local override is optional: skipped when it does not exist.
@Configuration()
@PropertySource([
  'file:config/app.properties',
  r'file:config/app-${env:local}.properties',
], ignoreResourceNotFound: true)
class AppConfig {}

Spring (Java):

@Configuration
@PropertySource(
    value = {"file:config/app.properties",
             "file:config/app-${env:local}.properties"},
    ignoreResourceNotFound = true)
class AppConfig {}

Constructors

PropertySource(List<String> value, {String? name, bool ignoreResourceNotFound = false, Type? factory, String? encoding})
Adds the files at the resource locations value.
const

Properties

encoding → String?
The charset of the files, such as 'ISO-8859-1'; UTF-8 when null.
final
factory → Type?
A PropertySourceFactory type with a no-argument constructor, to read another format; null reads .properties files.
final
hashCode → int
The hash code for this object.
no setterinherited
ignoreResourceNotFound → bool
Whether a missing file is skipped (true) or fails the startup (false, the default).
final
name → String?
Name of the resulting property source; derived from the location when null.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
value → List<String>
Resource locations of the property files (file:, resources:, patterns).
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited