Weld using alternative producer from src/test/META-INF/beans.xml

点点圈 提交于 2019-12-04 17:51:43

It seems a bug of Weld Se. It only use beans.xml version under src/main/resources/META-INF.

The solution is using beans.xml under CDI-SE src/main/resources/META-INF/beans.xml for test purpose and you may need to add < exclude> into beans.xml too.

You can have another production beans.xml file and when you export your code into deployment package (jar, war, ear). Don't forget to replace your testing beans.xml by your production beans.xml.

If you are developing web app. You can create your production beans.xml under WEB-INF. 2 version of beans.xml exists but only WEB-INF/beans.xml is used by WAS.

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd"
    version="1.1" bean-discovery-mode="all">
    <scan>
        <exclude name="org.jboss.weld.**" />
        <exclude name="com.your_package.EngineProducer" />
    </scan>
    <alternatives>
        <class>com.test.testing.TestEngineProducer</class>
    </alternatives>
</beans>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!