PropertySourceDeclaration class final

One @PropertySource annotation, recorded in a BeanModule: which property files to add to the environment, and when.

The generator writes one per annotation. You only create one when you build a module by hand, for example in a test.

// A module that only adds an optional property file.
final module = BeanModule(
  'settings',
  const [],
  propertySources: const [
    PropertySourceDeclaration(
      ['file:config/app.properties'],
      ignoreResourceNotFound: true,
    ),
  ],
);

Spring (Java):

@Configuration
@PropertySource(value = "file:config/app.properties",
    ignoreResourceNotFound = true)
class Settings {}

Constructors

PropertySourceDeclaration(List<String> locations, {String? name, bool ignoreResourceNotFound = false, PropertySourceFactory factory = const DefaultPropertySourceFactory(), List<Condition> conditions = const [], String? encoding})
Declares the property files at the resource locations.
const

Properties

conditions → List<Condition>
The conditions of the declaring class; the files are loaded only when all of them match. So a @Profile(['prod']) class does not load its @PropertySource in other profiles, as in Spring.
final
encoding → String?
The charset name the files are read in (UTF-8 when null).
final
factory → PropertySourceFactory
Turns each file into a property source; the default 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 refresh (false, the default).
final
locations → List<String>
Resource locations (file:, resources:, patterns); may contain ${...} placeholders.
final
name → String?
Name of the property source; derived from the location when null.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

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