All we need to do to take advantage of Contexts and Dependency Injection features in our Web Application projects is to click on the checkbox labeled Enable Contexts and Dependency Injection on the second page of the New Web Application wizard.
In most cases will want to use the JSF 2.0 framework as well, since typically CDI applications use JSF as their user interface component framework.
Clicking on the Enable Contexts and Dependency Injection checkbox has the effect of creating a file called
beans.xml
and placing it in the WEB-INF
directory of our web application. The generated beans.xml
file looks like this:
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/beans_1_0.xsd"> </beans>
When our application is deployed, the presence of this file indicates to the...