如何使用CDI 1.0从扫描中排除类

问题描述:

我想在CDI 1.0中排除扫描类。我在WebLogic 12.1.12中使用了CDI的默认实现(Weld,CDI 1.0)。

I would like to exclude a class from scanning in CDI 1.0. I'm using the default implementation of CDI in WebLogic 12.1.12 (Weld, CDI 1.0).

我看到了几个带有CDI 1.1的网站和文档,但没有使用以前的版本。

I saw several web sites and docs with CDI 1.1 but not with the previous release .

使用Weld,您可以在 beans.xml中使用自定义XML命名空间从扫描中排除类:

With Weld, you can use a custom XML namespace in beans.xml to exclude classes from scanning:

 <beans xmlns="http://java.sun.com/xml/ns/javaee" 
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
   xmlns:weld="http://jboss.org/schema/weld/beans">
   <weld:scan>
     <weld:exclude name="com.acme.swing.**"/>
   </weld:scan>
 </beans>

参见焊接手册了解详情。