我在使用Weld-SE (Java SE)时注意到,如果类路径中有很多JAR,JVM启动时间将达到几秒。
有没有办法将扫描路径指定/限制为包模式或路径模式,就像Apache Ant或AspectJ中那样?
注:在Weld论坛上注册不起作用-它一直在说“你的密码很简单”。
发布于 2011-08-22 03:03:36
从weld 1.1.0开始,根据Weld reference documentation:
<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"
xsi:schemaLocation="
http://java.sun.com/xml/ns/javaee http://docs.jboss.org/cdi/beans_1_0.xsd
http://jboss.org/schema/weld/beans http://jboss.org/schema/weld/beans_1_1.xsd">
<weld:scan>
<weld:exclude name="mypackage.MyClass"/>
</weld:scan>
</beans>发布于 2014-01-21 11:57:11
您可以使用CDI 1.1。第一个答案很好,但这段代码适用于任何提供商:
<?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="my.cool.package" />
<!-- you can exclude with condition -->
<exclude name="my.cool.package.for.jodatime" />
<if-class-not-available name="org.joda.time.LocalDate"/>
</exclude>
</scan>
</beans>发布于 2011-08-22 00:07:52
问得好,但我不认为这是可能的。将按规范扫描每个归档文件中的beans.xml。
https://stackoverflow.com/questions/7114920
复制相似问题