Package io.micronaut.context.annotation
Annotation Type Configuration
-
@Documented @Target(PACKAGE) public @interface Configuration
A configuration is a grouping of bean definitions under a package. A configuration can have requirements applied to it with
Requires
such that the entire configuration only loads of the requirements are met. For example consider the followingpackage-info.java
file:@Configuration @Requires(classes = Cluster.class) package io.micronaut.configuration.cassandra; import com.datastax.driver.core.Cluster; import io.micronaut.context.annotation.Configuration; import io.micronaut.context.annotation.Requires;
In the example above the
Requires
annotation ensures all beans contained within the package are loaded only if theCluster
class is present on the classpath.The
ApplicationContextBuilder.include(String...)
andApplicationContextBuilder.exclude(String...)
methods can also be used to control which configurations are loaded when building theApplicationContext
- Since:
- 1.0
- See Also:
Requires
,ApplicationContextBuilder.exclude(String...)