Profile class
Registers a bean only when the active profiles match.
Profiles name the situations an application runs in (dev, test,
prod). They are activated with the spring.profiles.active property
or Environment.setActiveProfiles. Use @Profile to swap
implementations between them, for example an in-memory mailer during
development. Each entry is a profile expression: 'dev', '!prod',
'eu & (dev | test)'. The bean is registered when any entry matches.
On a configuration class it applies to all its @Bean methods and to
its @PropertySource files. Subclass it to name a set of profiles once:
class Dev extends Profile { const Dev() : super(const ['dev']); }.
@Component()
@Profile(['dev', 'test'])
class InMemoryMailer implements Mailer { ... }
// The InMemoryMailer bean exists in this context only.
final env = StandardEnvironment()..setActiveProfiles(['dev']);
final context = ApplicationContext.run([appBeans], environment: env);
Spring (Java):
@Component
@Profile({"dev", "test"})
class InMemoryMailer implements Mailer { ... }
Properties
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