【发布时间】:2012-10-14 21:55:21
【问题描述】:
我使用 Weld 作为 CDI 实现。当我在src/test/java/META-INF/beans.xml 中有空 beans.xml 时,我的集成测试尝试组装对象图实例化 Weld 容器运行良好。这是一个简单的测试:
public class WeldIntegrationTest {
@Test
public void testInjector() {
new Weld().initialize();
// shouldn't throw exception
}
}
现在当我运行mvn clean install 时,我总是得到:Missing beans.xml file in META-INF!
我的根文件夹是“src”和“web”,其中包含 WEB-INF 文件夹,但我也尝试使用默认的 maven 结构并将“web”重命名为“webapp”并将其移至 src/main。我尝试了所有我能想到的合理位置:
- src/main/java/META-INF/beans.xml
- src/test/java/META-INF/beans.xml
- web/WEB-INF/beans.xml
- src/main/webapp/WEB-INF/beans.xml
- src/main/webapp/META-INF/beans.xml
- src/main/webapp/META-INF/(empty) and src/main/webapp/WEB-INF/beans.xml
到目前为止没有任何效果:/
【问题讨论】:
-
在我的 CDI 项目中 beans.xml 在 src\main\webapp\WEB-INF 中,在我的 war 文件中它也在 WEB-INF 目录中。
标签: java jakarta-ee maven cdi jboss-weld