Annotation Interface 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 following package-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 the Cluster class is present on the classpath.

The ApplicationContextBuilder.include(String...) and ApplicationContextBuilder.exclude(String...) methods can also be used to control which configurations are loaded when building the ApplicationContext

Since:
1.0
Author:
Graeme Rocher
See Also: