Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用WildFly的Spring依赖注入_Spring_Dependency Injection_Wildfly_Weld - Fatal编程技术网

使用WildFly的Spring依赖注入

使用WildFly的Spring依赖注入,spring,dependency-injection,wildfly,weld,Spring,Dependency Injection,Wildfly,Weld,我有一个web应用程序(war文件),它依赖于(Maven)另一个使用Spring进行依赖注入的项目(jar文件)。所以在另一个项目中,我有两个xml文件来声明我的bean,在我的例子中是业务对象。我开始使用WildFly而不是Tomcat/Jetty,显然有一个叫做Weld的东西负责DI。我的web应用程序不使用Spring(目前),它只是一个简单的RESTful API。 我希望我的业务对象在我的资源(控制器)中是可注入的(@Inject) 我如何使我的bean变得容易访问,这意味着我们如何

我有一个web应用程序(war文件),它依赖于(Maven)另一个使用Spring进行依赖注入的项目(jar文件)。所以在另一个项目中,我有两个xml文件来声明我的bean,在我的例子中是业务对象。我开始使用WildFly而不是Tomcat/Jetty,显然有一个叫做Weld的东西负责DI。我的web应用程序不使用Spring(目前),它只是一个简单的RESTful API。
我希望我的业务对象在我的资源(控制器)中是可注入的(@Inject)

我如何使我的bean变得容易访问,这意味着我们如何混合Spring DI和WildFly DI

现在,在我的web应用程序项目中,我有一个web-INF/beans.xml文件,其中包含以下内容:

<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:weld="http://jboss.org/schema/weld/beans"
    xsi:schemaLocation="
    http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd
    http://jboss.org/schema/weld/beans http://jboss.org/schema/weld/beans_1_1.xsd
    bean-discovery-mode="all">
</beans>
我得到这个错误:

WELD-001408:SomeBO类型与限定符@Default的未满足依赖关系

谢谢

编辑
我需要用xml文件导入bean,我不想对它们进行注释,例如,我有一个bo.xml文件(SpringBeans),其中包含这样的声明:

    <bean id="com.xxx.bo.SomeBO" parent="com.xxx.bo._AbstractBO">
        <property name="target">
            <bean class="com.xxx.bo.SomeBOImpl">
                <property name="DAO" ref="com.xxx.dao.SomeDAO"/>
            </bean>
        </property>
    </bean>

WildFly实现了JavaEE规范,这意味着它为提供了一个实现。在WildFly的例子中,它使用了参考实现,即Weld。对于JavaEE6,有一些可以很好地解释CDI


至于您的错误,您可能只需要使用
@Named
或有效的CDI注释对SomBO实现进行注释,使其成为CDI管理的bean。

请参阅我的编辑,我需要使用xml声明,这意味着我需要让WildFly/Weld知道这些文件。使用CDI可能需要对它们进行注释。老实说,我不确定beans.xml文件中有什么内容,所以它可能是可配置的。
    <bean id="com.xxx.bo.SomeBO" parent="com.xxx.bo._AbstractBO">
        <property name="target">
            <bean class="com.xxx.bo.SomeBOImpl">
                <property name="DAO" ref="com.xxx.dao.SomeDAO"/>
            </bean>
        </property>
    </bean>