如何在WildFly上禁用WELD

时间:2014-02-13 14:15:45

标签: java jboss cdi weld wildfly

如何在WildFly上完全禁用WELD。我不需要它,因为我使用另一个DI框架。

  

例外0:   javax.enterprise.inject.UnsatisfiedResolutionException:无法解析 'org.springframework.data.mongodb.core.MongoOperations' 与预选赛[@ javax.enterprise.inject.Any(豆),@ javax.enterprise.inject.Default( )]。       在org.springframework.data.mongodb.repository.cdi.MongoRepositoryExtension.createRepositoryBean(MongoRepositoryExtension.java:104)       在org.springframework.data.mongodb.repository.cdi.MongoRepositoryExtension.afterBeanDiscovery(MongoRepositoryExtension.java:79)       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)       at java.lang.reflect.Method.invoke(Method.java:606)       at org.jboss.weld.injection.MethodInjectionPoint.invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:93)       at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:266)       在org.jboss.weld.event.ExtensionObserverMethodImpl.sendEvent(ExtensionObserverMethodImpl.java:125)       at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:253)       at org.jboss.weld.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:232)       在org.jboss.weld.event.ObserverNotifier.notifyObserver(ObserverNotifier.java:169)

我试过

<?xml version="1.0" encoding="UTF-8"?>
<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://java.sun.com/xml/ns/javaee/beans_1_0.xsd
                       http://jboss.org/schema/weld/beans http://jboss.org/schema/weld/beans_1_1.xsd
http://jboss.org/schema/weld/beans ">

<weld:scan>
    <weld:exclude name="com.google.**"/>
    <weld:exclude name="org.springframework.data.mongodb.**"/>
</weld:scan>

但它没有解决我的问题。

3 个答案:

答案 0 :(得分:14)

有标准方式:

<?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="none">
</beans>

答案 1 :(得分:14)

选项1:战争中的jboss-all.xml

这是特定于Weld的,但它禁用了Weld对整个部署的自动bean扫描(例如war文件及其中的所有jar)。如果您无法轻松将beans.xml添加到第三方jar(例如jboss-seam-resteasy.jar),这很方便。

对于战争保存为WEB-INF/jboss-all.xml,否则为META-INF/jboss-all.xml

<jboss xmlns="urn:jboss:1.0">
    <weld xmlns="urn:jboss:weld:1.0" require-bean-descriptor="true"/>
</jboss>

请参阅Per-deployment configuration

选项2:WildFly中的standalone.xml

另一个不需要更改应用程序本身的选项是configure the weld subsystem not to treat random jars as CDI libraries。只需在WildFly standalone.xml中编辑焊接配置,如下所示:

<subsystem xmlns="urn:jboss:domain:weld:2.0" require-bean-descriptor="true"/>

答案 2 :(得分:5)

尝试删除或评论org.jboss.as.weld开头的扩展程序列表中的$JBOSS_HOME/standalone/configuration/standalone.xml扩展名。您可能还想从<subsystem xmlns="urn:jboss:domain:weld:1.0"/>中删除<profile>。这应该导致对服务器上部署的所有应用程序禁用Weld。

相关问题