1、在webapp/META-INFO/下建立context.xml
<?xml version="1.0" encoding="UTF-8"?>
<Context>
<Resource name="BeanManager"
auth="Container"
type="javax.enterprise.inject.spi.BeanManager"
factory="org.jboss.weld.resources.ManagerObjectFactory" />
<WatchedResource>WEB-INFweb.xml</WatchedResource>
<WatchedResource>META-INFcontext.xml</WatchedResource>
</Context>
2、在web.xml里
<resource-env-ref>
<resource-env-ref-name>BeanManager</resource-env-ref-name>
<resource-env-ref-type>
javax.enterprise.inject.spi.BeanManager
</resource-env-ref-type>
</resource-env-ref>
我没有把cdi的包放在tomcat/lib下。
我的测试环境为tomcat8 rc5