public interface Environment extends PropertyResolver, LifeCycle<Environment>, ConversionService<Environment>, ResourceLoader
The current application environment. The environment represents the loaded configuration of the application for a current list of active environment names.
The active environment names can be obtained from the getActiveNames() method and are established from one
 of the following sources:
 
ApplicationContext.run(String...) methodENVIRONMENTS_PROPERTY system propertyENVIRONMENTS_ENV environment variableWhen establishing the environment name from the class the started the application Micronaut will inspect the stacktrace. If JUnit or Spock are
 featured in the stacktrace the TEST environment is included. When running from Android the ANDROID environment is included.
| Modifier and Type | Field and Description | 
|---|---|
| static String | AMAZON_EC2Cloud provider amazon ec2. | 
| static String | ANDROIDThe android environment. | 
| static String | AZURECloud provider Microsoft Azure. | 
| static String | BARE_METALCloud or non cloud provider on bare metal (unknown). | 
| static String | BOOTSTRAP_CONTEXT_PROPERTYWhether the bootstrap context is enabled. | 
| static String | BOOTSTRAP_NAMEThe default bootstrap config name. | 
| static String | BOOTSTRAP_NAME_PROPERTYSystem property to override the default bootstrap name. | 
| static String | CLIThe cli environment. | 
| static String | CLOUDThe cloud environment. | 
| static String | CLOUD_FOUNDRYRunning on Cloud Foundry. | 
| static String | CLOUD_PLATFORM_PROPERTYThe default bootstrap name. | 
| static String | DEDUCE_ENVIRONMENT_ENVEnvironment key for whether to deduce environments. | 
| static String | DEDUCE_ENVIRONMENT_PROPERTYProperty for whether to deduce environments. | 
| static String | DEFAULT_NAMEThe default application name. | 
| static String | DEVELOPMENTThe development environment. | 
| static String | DIGITAL_OCEANCloud provider Digital Ocean. | 
| static String | ENVIRONMENTS_ENVThe environment key that stores additional environments. | 
| static String | ENVIRONMENTS_PROPERTYThe property that stores additional environments. | 
| static String | FUNCTIONThe application is executing as a function. | 
| static String | GAECloud provider for google app engine. | 
| static String | GOOGLE_COMPUTECloud provider google compute instance. | 
| static String | HEROKURunning on Heroku. | 
| static String | HOSTNAMEThe host name environment variable. | 
| static String | IBMCloud provider IBM cloud. | 
| static String | KUBERNETESRunning on Kubernetes. | 
| static String | MICRONAUTConstant for the name micronaut. | 
| static String | ORACLE_CLOUDCloud provider Oracle Cloud. | 
| static String | PROPERTY_SOURCES_KEYThe key used to load additional property sources. | 
| static String | TESTThe test environment. | 
SHARED| Modifier and Type | Method and Description | 
|---|---|
| Environment | addConfigurationExcludes(String... names)Exclude configurations by name. | 
| Environment | addConfigurationIncludes(String... names)Exclude configurations by name. | 
| default Environment | addPackage(Package pkg)Add an application package. | 
| Environment | addPackage(String pkg)Add an application package. | 
| Environment | addPropertySource(PropertySource propertySource)Adds a property source to this environment. | 
| default Environment | addPropertySource(String name,
                 Map<String,? super Object> values)Add a property source for the given map. | 
| Set<String> | getActiveNames()Should respect the order as provided. | 
| default ClassLoader | getClassLoader() | 
| Collection<String> | getPackages() | 
| PropertyPlaceholderResolver | getPlaceholderResolver() | 
| Collection<PropertySourceLoader> | getPropertySourceLoaders()Obtains the  PropertySourceLoaderinstances. | 
| Collection<PropertySource> | getPropertySources() | 
| boolean | isActive(BeanConfiguration configuration)Whether the current environment includes the given configuration. | 
| default boolean | isPresent(String className)Check whether the given class is present within this environment. | 
| Map<String,Object> | refreshAndDiff()Refresh the environment from the list of  PropertySourceinstances and return a diff of the changes. | 
| Environment | removePropertySource(PropertySource propertySource)Removes a property source from this environment. | 
| default Stream<Class<?>> | scan(Class<? extends Annotation> annotation)Scan the current environment for classes annotated with the given annotation. | 
| default Stream<Class<?>> | scan(Class<? extends Annotation> annotation,
    String... packages)Scan the current environment for classes annotated with the given annotation. | 
containsProperties, containsProperty, get, getProperties, getProperties, getProperty, getProperty, getProperty, getProperty, getProperty, getPropertyEntries, getRequiredProperty, nameOfget, get, getclose, isRunning, refresh, start, stopaddConverter, addConverter, canConvert, convert, convert, convert, convert, convertRequired, convertRequiredforBase, getResource, getResourceAsStream, getResources, supportsPrefixstatic final String MICRONAUT
static final String TEST
static final String DEVELOPMENT
static final String ANDROID
static final String CLI
static final String CLOUD
static final String FUNCTION
static final String BOOTSTRAP_NAME_PROPERTY
static final String BOOTSTRAP_CONTEXT_PROPERTY
static final String CLOUD_PLATFORM_PROPERTY
static final String ENVIRONMENTS_PROPERTY
static final String ENVIRONMENTS_ENV
static final String BOOTSTRAP_NAME
static final String DEFAULT_NAME
static final String GOOGLE_COMPUTE
static final String GAE
static final String AMAZON_EC2
static final String AZURE
static final String ORACLE_CLOUD
static final String DIGITAL_OCEAN
static final String BARE_METAL
static final String IBM
static final String KUBERNETES
static final String CLOUD_FOUNDRY
static final String HEROKU
static final String PROPERTY_SOURCES_KEY
static final String HOSTNAME
static final String DEDUCE_ENVIRONMENT_PROPERTY
static final String DEDUCE_ENVIRONMENT_ENV
Set<String> getActiveNames()
Collection<PropertySource> getPropertySources()
Environment addPropertySource(PropertySource propertySource)
propertySource - The property sourceEnvironment removePropertySource(PropertySource propertySource)
propertySource - The property sourceEnvironment addPackage(String pkg)
pkg - The package to addEnvironment addConfigurationExcludes(String... names)
names - The names of the configurationEnvironment addConfigurationIncludes(String... names)
names - The names of the configurationCollection<String> getPackages()
PropertyPlaceholderResolver getPlaceholderResolver()
Map<String,Object> refreshAndDiff()
PropertySource instances and return a diff of the changes.default Environment addPropertySource(String name, @Nullable Map<String,? super Object> values)
name - The namevalues - The valuesdefault Environment addPackage(Package pkg)
pkg - The package to adddefault Stream<Class<?>> scan(Class<? extends Annotation> annotation)
annotation - The annotation to scandefault Stream<Class<?>> scan(Class<? extends Annotation> annotation, String... packages)
annotation - The annotation to scanpackages - The packages to scandefault ClassLoader getClassLoader()
default boolean isPresent(String className)
className - The class nameboolean isActive(BeanConfiguration configuration)
configuration - The configurationCollection<PropertySourceLoader> getPropertySourceLoaders()
PropertySourceLoader instances.PropertySourceLoader