简体   繁体   English

Maven beans.xml

[英]Maven beans.xml

Im using maven and weld. 我正在使用Maven和焊接。 I have created beans.xml but while im starting app (java application) i have error like this: 我创建了beans.xml,但是在我启动应用程序(java应用程序)时却出现如下错误:

enter image description here 在此处输入图片说明

my pom.xml 我的pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.kamczi</groupId>
  <artifactId>maven-di</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <dependencies>
        <dependency>
            <groupId>org.jboss.weld.se</groupId>
            <artifactId>weld-se</artifactId>
            <version>2.3.2.Final</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.0</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

my error: Exception in thread "main" java.lang.IllegalStateException: WELD-ENV-000016: Missing beans.xml file in META-INF at org.jboss.weld.environment.se.Weld.initialize(Weld.java:539) at com.kamczi.Main.main(Main.java:10) 我的错误:线程“ main”中的异常java.lang.IllegalStateException:WELD-ENV-000016:META-INF中的org.jboss.weld.environment.se.Weld.initialize(Weld.java:539 )在com.kamczi.Main.main(Main.java:10)

I would say the problem here is that you have your beans.xml under src/test/... while Weld presumes there is one in src/main/... . 我要说的问题是,您在src/test/...下有beans.xml ,而Weld假定src/main/...有一个。

If it is testing you are after, then I suggest you either use a synthetic bean archive in case you are in SE or, if in EE, then you can leverage Shrinkwrap and Arquillian to create a deployment with whatever beans.xml you want. 如果是测试你以后,那么我建议你要么使用的情况下,合成的豆存档你是在SE或者,如果EE,那么你可以利用拆封和的Arquillian创建与任何部署beans.xml你想要的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM