How to exclude a class from scanning with CDI 1.0

Alexandre T picture Alexandre T · Mar 14, 2014 · Viewed 9.7k times · Source

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 .

Answer

Harald Wellmann picture Harald Wellmann · Mar 14, 2014

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.