为tomcat8配置BeanManger。

来源:互联网 发布:mic是什么软件 编辑:程序博客网 时间:2024/05/21 19:36

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

原创粉丝点击