0

私は、XMLでAnnotaionsとSpringIOCの組み合わせを使用するSpringProject:Commonに取り組んでいます。さまざまなプロジェクトで使用されるCommonクラスを含むcommon.jarがあります。

そして、common.jarで定義されたBeanを参照する別のSpring Project:WebServiceがあります。

何らかの理由で、Common.jarで@Component AnnotationとマークされたBeanが、私のWebServiceプロジェクトによって取得されていません。ただし、Common.jarで<bean id = "" class =""/>を使用して定義されたすべてのBeanが取得されました。

以下は、必要な構成を持つすべてのファイルのコードです。本当にあなたの助けをいただければ幸いです。前もって感謝します。

Common.jarでは、applicationContext.xml

   <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:aop="http://www.springframework.org/schema/aop"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
    http://www.springframework.org/schema/context
    http://www.springframework.org/schema/context/spring-context.xsd
    http://www.springframework.org/schema/aop
    http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">

    <import resource="springConfig/app/AppServices.xml"/> <!-- Beans in this file were loaded. -->

    <context:annotation-config/>
    <context:component-scan base-package="com.ipd.app1"/> <!-- Beans for all classes under app1 package were NOT loaded  -->

</beans>

Common.jarでは、AppServices.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">

    <bean id="inquireOrderApp" class="com.ipd.app.inquireOrderDetail.InquireOrderDetailAppImpl"/>

</beans>

Common.jar、com.test.app.MyClass

package com.ipd.app1;
    @Component("createOrderApp")
    public class CreateOrderAppImpl implements CreateOrderApp {
        @Override   
        public CreateOrderResponse processMSSOrder(TransactionContext tx,
                CreateOrderRequest createOrderRequest)
                throws ApplicationException, Exception {

            System.out.println("In App Layer Class CreateOrderAppImpl to ProcessOrder.");
            return response;
        }
    }

WebServiceプロジェクト、IpdService_IPDSoapHTTPPortImpl.java

 @WebService(portName = "IpdSoapHTTPPort", serviceName = "IpdService", targetNamespace = "http://ipd.com/ipdIpdweb/", wsdlLocation = "/wsdls/Ipd.wsdl", endpointInterface = "com.ipd.ipdIpdweb.IpdPortType")
@BindingType("http://schemas.xmlsoap.org/wsdl/soap/http")
public class IpdService_IpdSoapHTTPPortImpl implements IpdPortType {

    ApplicationContext ctx;

    public IpdService_IpdSoapHTTPPortImpl() {
        this.ctx = AppContext.getCtx();
    }

    @Override
    public void createOrder(WSHeader wsHeader,
            CreateOrderRequest createOrderRequest,
            Holder<WSResponseHeader> wsResponseHeader,
            Holder<CreateOrderResponse> createOrderResponse)
            throws WSException {


            CreateOrderApp createOrderApp = (CreateOrderApp) ctx.getBean("createOrderApp");         
            res = createOrderApp.processOrder(tx, createOrderRequest);

            res.setResponseCode(BigInteger.valueOf(0));
            res.setResponseMessage("Success");

           .....
    }

}

他のファイルのコードを確認する必要がある場合は、お知らせください。

4

1 に答える 1