0
我想要使用推土機映射兩個類。但每次我輸入映射類的方法時,拋出以下錯誤:Dozer org.apache.commons.lang.ClassUtils.getClass(Ljava/lang/String;)錯誤
org.apache.commons.lang.ClassUtils.getClass(Ljava/lang/String;)
有人知道我在想什麼或做錯了什麼?
我src/main/resources
創建dozerBeanMapping.xml
並添加映射:加入到我的pom.xml
以下依存
<?xml version="1.0" encoding="UTF-8"?>
<mappings xmlns="http://dozer.sourceforge.net"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://dozer.sourceforge.net
http://dozer.sourceforge.net/schema/beanmapping.xsd">
<mapping>
<class-a>com.projectx.standard.services.user.model.Address</class-a>
<class-b>com.projectx.standard.dao.user.model.AddressDTO</class-b>
</mapping>
</mappings>
也:
<dependency>
<groupId>net.sf.dozer</groupId>
<artifactId>dozer</artifactId>
<version>5.3.1</version>
</dependency>
<dependency>
<groupId>org.apache.xmlbeans</groupId>
<artifactId>xmlbeans</artifactId>
<version>2.4.0</version>
<scope>runtime</scope>
</dependency>
我的類,其中映射是:
public void saveAddress(Address address) {
Mapper mapperBeanName = DozerBeanMapperSingletonWrapper.getInstance();
PostalCode postalCode = address.getPostalCode();
this.postalCodeService.savePostalCode(postalCode);
address.setFkPostalCode(postalCode.getId());
AddressDTO addressDTO = mapperBeanName.map(address, AddressDTO.class);
this.addressServiceDAO.saveAddress(addressDTO);
}
和堆棧跟蹤:
java.lang.NoSuchMethodError: org.apache.commons.lang.ClassUtils.getClass(Ljava/lang/String;)Ljava/lang/Class;
at org.dozer.util.DefaultClassLoader.loadClass(DefaultClassLoader.java:36)
at org.dozer.DozerInitializer.loadBeanType(DozerInitializer.java:115)
at org.dozer.DozerInitializer.initialize(DozerInitializer.java:97)
at org.dozer.DozerInitializer.init(DozerInitializer.java:74)
at org.dozer.DozerBeanMapper.init(DozerBeanMapper.java:164)
at org.dozer.DozerBeanMapper.(DozerBeanMapper.java:90)
at org.dozer.DozerBeanMapperSingletonWrapper.getInstance(DozerBeanMapperSingletonWrapper.java:43)
at com.projectx.standard.services.user.implementation.AddressTypeServiceImpl.getAddressTypes(AddressTypeServiceImpl.java:27)
at com.projectx.standard.app.controler.user.UserRegistrationController.loadModel(UserRegistrationController.java:72)
at com.projectx.standard.app.controler.user.UserRegistrationController.loadData(UserRegistrationController.java:50)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:219)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:100)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:604)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:565)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:923)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.__invoke(StandardContextValve.java:123)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.__invoke(StandardHostValve.java:171)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1041)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:603)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
謝謝
我不確定,但有時候會面臨這個問題,因爲該方法不存在於類中。 – Kick
你有commons-lang中的顯式依賴嗎?你能在pom中顯示整個依賴關係部分嗎? –
是的,我有這樣的依賴性:\t \t \t \t org.apache.commons \t \t \t 公地lang3 \t \t \t 3.2.1 \t \t –
amachado