Java Platform, Enterprise Edition (Java EE) 8 The Java EE Tutorial

## Configuring a CDI Application

When your beans are annotated with a scope type, the server recognizes the application as a bean archive and no additional configuration is required. The possible scope types for CDI beans are listed in Using Scopes.

CDI uses an optional deployment descriptor named `beans.xml`. Like other Java EE deployment descriptors, the configuration settings in `beans.xml` are used in addition to annotation settings in CDI classes. The settings in `beans.xml` override the annotation settings if there is a conflict. An archive must contain the `beans.xml` deployment descriptor only in certain limited situations, described in Chapter 27, "Contexts and Dependency Injection for Java EE: Advanced Topics".

For a web application, the `beans.xml` deployment descriptor, if present, must be in the `WEB-INF` directory. For EJB modules or JAR files, the `beans.xml` deployment descriptor, if present, must be in the `META-INF` directory.

Copyright © 2017, Oracle and/or its affiliates. All rights reserved.