2014-01-22 28 views
0

這裏是我的類我想要使用這個註解,我得到null的dozerBeanMapper。我也得空爲其他豆類我試圖使用像Jaxb2Mapper等Spring @Autowired註解給零推土機映射

@Service("Transformer") 
@Scope("prototype") 
public class Transformer { 

@Autowired 
private Mapper dozerBeanMapper; 

public Object testMethod(Object wlpData) throws TransformerException { 

    MbrReq destObject = null; 

    destObject = dozerBeanMapper.map(request, MbrReq.class); 

    return destObject; 
} 

這裏是我的配置:

<?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:sws="http://www.springframework.org/schema/web-services" 
xmlns:context="http://www.springframework.org/schema/context" 
xmlns:oxm="http://www.springframework.org/schema/oxm" xmlns:aop="http://www.springframework.org/schema/aop" 
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd 
    http://www.springframework.org/schema/web-services http://www.springframework.org/schema/web-services/web-services-2.0.xsd 
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd 
    http://www.springframework.org/schema/oxm http://www.springframework.org/schema/oxm/spring-oxm-3.1.xsd 
    http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd"> 
<sws:annotation-driven /> 
<context:component-scan base-package="com.xxxxx.xxxx.srvc.membership,com.xxxxx.xxxx.interact.membership.request,com.xxxxx.membership.ws,com.xxxxxx.srvc.membership.generated,com.xxxxx.xxxx.service.transform" /> 

<!-- WSDL Exposed as memberService --> 
<bean id="searchMemDemographics" class="org.springframework.ws.wsdl.wsdl11.SimpleWsdl11Definition"> 
    <constructor-arg value="/WEB-INF/schema/MemSvc_Binding_HTTP_V0100.wsdl"/> 
</bean> 

<bean class="org.dozer.spring.DozerBeanMapperFactoryBean"> 
    <property name="mappingFiles"> 
     <list> 
      <value>classpath:mapping/dozer-global-configuration.xml</value> 
      <value>classpath:mapping/dozer-bean-mappings.xml</value> 
     </list> 
    </property> 
</bean> 

<oxm:jaxb2-marshaller id="marshaller" contextPath="com.xxxxx.srvc.membership" /> 

<oxm:jaxb2-marshaller id="reqMarshaller" contextPath="com.xxxxxx.membership.request" /> 

<oxm:jaxb2-marshaller id="respMarshaller" contextPath="com.xxxxxx.membership.response" /> 

在web.xml中我有這個

<context-param> 
    <param-name>contextConfigLocation</param-name> 
    <param-value> 
      classpath:spring/membershipApplicationContext.xml 
      </param-value> 
</context-param> 

還有什麼我不知道?

回答

0

嘗試向bean添加一個id。

<bean id="dozerBeanMapper" class="org.dozer.spring.DozerBeanMapperFactoryBean">