我使用Weld作为CDI实现.当我有空的beans.xml时,我试图组装实例化Weld容器的对象图的集成测试运行良好src/test/java/META-INF/beans.xml.这是一个简单的测试:
public class WeldIntegrationTest {
@Test
public void testInjector() {
new Weld().initialize();
// shouldn't throw exception
}
}
Run Code Online (Sandbox Code Playgroud)
现在,当我跑步时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
Run Code Online (Sandbox Code Playgroud)
到目前为止没有任何作用:/