Search code examples
jakarta-eecdiweblogic12cweld

How to exclude a class from scanning with 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).

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


Solution

  • 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>
    

    See the Weld Manual for details.