简体   繁体   English

来自lib的jar中的META-INF中的CDI WELD Beans.xml阻止了项目的WEB-INF中的一个

[英]CDI WELD Beans.xml in META-INF from jar in lib blocking the one in WEB-INF of project

Depending on where I place my beans.xml's, in my project CDI is either working for @Named annotated classes found in lib jars OR for @Alternative annotated classes found in the main project. 根据在我的项目中放置bean.xml的位置的不同,CDI可以用于在lib jar中找到的@Named注释类,也可以用于在主项目中找到的@Alternative注释类。 I can't figure out where to place them to get both to work. 我不知道在哪里放置它们才能使它们都正常工作。

Upon building I have a core.jar that has some @Default annotated classes and some @Named annotated classes. 构建后,我有一个core.jar,其中包含一些@Default注释类和一些@Named注释类。

The core.jar is located in the web-inf/lib in my project. core.jar位于我的项目中的web-inf / lib中。

In that project, depending on environment build, I use some @Alternative annotated classes which are specified in the beans.xml of the web project (in WEB-INF) 在该项目中,根据环境的构建,我使用一些@Alternative注释的类,这些类在Web项目的bean.xml中指定(在WEB-INF中)

So, I have 2 beans.xml 所以,我有2 beans.xml

1 in the META-INF of a core.jar that is build and placed in the project lib AND 1 in the WEB-INF of the war project that gets deployed (with alternatives specified) 在core.jar的META-INF中为1,该core.jar已构建并放置在项目lib中,而在部署的war项目的WEB-INF中为1(指定了替代方案)

With both beans.xml files at those locations, the beanhandler does not find the alternatives specified in the beans.xml (the one in the web-inf of the war) 在两个bean.xml文件都位于这些位置的情况下,beanhandler找不到在bean.xml中指定的替代项(战争的web-inf中的那个)

When I remove the beans.xml from the META-INF from the jar dependency and redeploy, the alternatives are working fine (strangely) but then the @Named annotated classes are no longer found... 当我从jar依赖项中从META-INF中删除bean.xml并重新部署时,替代方法工作正常(奇怪),但是随后不再找到@Named注释类...

Any ideas? 有任何想法吗?

Could you try: 您可以尝试:

From CDI 1.1 onwards the alternative can be enabled for the whole
 application using @Priority annotation.

As described in alternatives then you would not need to depend on beans.xml as activation point for the alternatives. 替代方案中所述,那么您无需依赖beans.xml作为替代方案的激活点。

暂无
暂无

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

相关问题 焊接,Tomcat:META-INF 中缺少“beans.xml” - Weld, Tomcat: missing “beans.xml” in META-INF 使用src / test / META-INF / beans.xml中的替代生产者进行焊接 - Weld using alternative producer from src/test/META-INF/beans.xml 可以从WEB-INF \\ lib \\ {*。jar} \\ META-INF \\ resources \\ WEB-INF目录访问tld文件吗? - Can tld files be accessed from WEB-INF\lib\{*.jar}\META-INF\resources\WEB-INF directory? 将bean.xml文件放入META-INF目录时的异常 - Exceptions when placing a beans.xml file into the META-INF dir 为什么喜欢/ WEB-INF / lib到/META-INF/MANIFEST.MF用于webapps? - Why prefer /WEB-INF/lib to /META-INF/MANIFEST.MF for webapps? gradle可以自动创建META-INF,WEB-INF文件夹和web.xml吗? - Can gradle create META-INF, WEB-INF folder and web.xml automatically? Google App Engine WEB-INF和META-INF - Google App Engine WEB-INF and META-INF 使用Maven pom.xml在WAR中未创建除WEB-INF和META-INF以外的目录 - Directory not creating other than WEB-INF & META-INF in WAR using Maven pom.xml 启动 JBoss 时出错 - 无法读取提供的索引:/content/&lt;<warfile> &gt;r/WEB-INF/lib/camel-api-3.0.1.jar/META-INF/jandex.idx</warfile> - Error while starting JBoss - Could not read provided index: /content/<<warFile>>r/WEB-INF/lib/camel-api-3.0.1.jar/META-INF/jandex.idx Maven:将 war/web-inf/classes 中的类作为 jar 添加到 war/web-inf/lib - Maven: Adding classes from war/web-inf/classes as a jar to war/web-inf/lib
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM