2016-09-19 8 views
1

私はXMLへのXMLオブジェクトコンバータをSpring統合サービスに組み込む方法を探していました。これは私が既に存在しているはずのものですが、私が抱えている問題は古いバージョンのSpring統合に基づいてドキュメントとチュートリアルを探し続けていることです。バネ統合でXMLをJavaオブジェクトに変換する適切な方法は何ですか?

私が変換しようとしているクラスは、javax.xml.bind.annotationで注釈が付けられています。

これは...私はthis pageのオフに基づいていた私のサービスで、これまで持っているもの

<?xml version="1.0" encoding="UTF-8"?> 
<beans xmlns="http://www.springframework.org/schema/beans" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:int="http://www.springframework.org/schema/integration" 
    xmlns:file="http://www.springframework.org/schema/integration/file" 
    xmlns:feed="http://www.springframework.org/schema/integration/feed" 
    xmlns:jms="http://www.springframework.org/schema/integration/jms" 
    xmlns:int-xml="http://www.springframework.org/schema/integration/xml" 
    xmlns:oxm="http://www.springframework.org/schema/oxm" 
    xsi:schemaLocation="http://www.springframework.org/schema/integration/feed http://www.springframework.org/schema/integration/feed/spring-integration-feed.xsd 
     http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd 
     http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd 
     http://www.springframework.org/schema/integration/file http://www.springframework.org/schema/integration/file/spring-integration-file.xsd 
     http://www.springframework.org/schema/integration/jms http://www.springframework.org/schema/integration/jms/spring-integration-jms.xsd 
     http://www.springframework.org/schema/integration/xml http://www.springframework.org/schema/integration/xml/spring-integration-xml-4.2.xsd 
     http://www.springframework.org/schema/oxm http://www.springframework.org/schema/oxm/spring-oxm-3.0.xsd"> 

    ............. 

    <bean id="unmarshallingTransformer" class="org.springframework.integration.xml.transformer.UnmarshallingTransformer"> 
     <constructor-arg> 
      <bean class="org.springframework.oxm.jaxb.Jaxb2Marshaller"> 
       <property name="contextPath" value="com.bottomline.cfrm.amq_wfs_bridge.model.audit" /> 
      </bean> 
     </constructor-arg> 
    </bean> 

    <int-xml:unmarshalling-transformer id="defaultUnmarshaller" 
    input-channel="channel_1" output-channel="channel_2" 
    unmarshaller="unmarshallingTransformer"/> 

    ............. 

</beans> 

あるしかし、私はこれをしようとすると、私が得る...

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.integration.xml.transformer.UnmarshallingTransformer#0': Unsatisfied dependency expressed through constructor argument with index 0 of type [org.springframework.oxm.Unmarshaller]: Could not convert constructor argument value of type [org.springframework.integration.xml.transformer.UnmarshallingTransformer] to required type [org.springframework.oxm.Unmarshaller]: Failed to convert value of type [org.springframework.integration.xml.transformer.UnmarshallingTransformer] to required type [org.springframework.oxm.Unmarshaller]; nested exception is java.lang.IllegalStateException: Cannot convert value of type [org.springframework.integration.xml.transformer.UnmarshallingTransformer] to required type [org.springframework.oxm.Unmarshaller]: no matching editors or conversion strategy found 
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:724) ~[spring-beans-4.2.7.RELEASE.jar:4.2.7.RELEASE] 
    at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:185) ~[spring-beans-4.2.7.RELEASE.jar:4.2.7.RELEASE] 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1143) ~[spring-beans-4.2.7.RELEASE.jar:4.2.7.RELEASE] 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1046) ~[spring-beans-4.2.7.RELEASE.jar:4.2.7.RELEASE] 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:510) ~[spring-beans-4.2.7.RELEASE.jar:4.2.7.RELEASE] 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) ~[spring-beans-4.2.7.RELEASE.jar:4.2.7.RELEASE] 
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.2.7.RELEASE.jar:4.2.7.RELEASE] 
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.2.7.RELEASE.jar:4.2.7.RELEASE] 
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.2.7.RELEASE.jar:4.2.7.RELEASE] 
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.2.7.RELEASE.jar:4.2.7.RELEASE] 
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772) ~[spring-beans-4.2.7.RELEASE.jar:4.2.7.RELEASE] 
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:839) ~[spring-context-4.2.7.RELEASE.jar:4.2.7.RELEASE] 
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538) ~[spring-context-4.2.7.RELEASE.jar:4.2.7.RELEASE] 
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118) ~[spring-boot-1.3.6.RELEASE.jar:1.3.6.RELEASE] 
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:760) ~[spring-boot-1.3.6.RELEASE.jar:1.3.6.RELEASE] 
    at org.springframework.boot.SpringApplication.createAndRefreshContext(SpringApplication.java:360) ~[spring-boot-1.3.6.RELEASE.jar:1.3.6.RELEASE] 
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:306) ~[spring-boot-1.3.6.RELEASE.jar:1.3.6.RELEASE] 
    at com.bridge.Application.main(Application.java:14) [classes/:na] 

答えて

1

わかりませんあなたが到達しようとしているが、あなたのStackTraceはあなたが必要なものがすべてと言うと、あなたが見逃している:

Could not convert constructor argument value of type [org.springframework.integration.xml.transformer.UnmarshallingTransformer] to required type [org.springframework.oxm.Unmarshaller] 

ルックを、あなたのコードがあります以下のような:

unmarshaller="unmarshallingTransformer" 

unmarshallingTransformerUnmarshallingTransformer型であるが、それは、org.springframework.oxm.Unmarshallerようになり、それを必要とします。

Jaxb2Marshaller beanを設定し、そのunmarshallerプロパティへの参照として使用することを検討してください。

UnmarshallingTransformerを手動で設定する必要はありません。 <int-xml:unmarshalling-transformer>がそれを行います。

+0

Jaxb2Marshallerを設定していただきありがとうございました。私はunmarshallingTransformerをBeanとして宣言している例について混乱しました。 –

関連する問題