gpt4 book ai didi

java - Dozer org.apache.commons.lang.ClassUtils.getClass(Ljava/lang/String;) 错误

转载 作者:行者123 更新时间:2023-12-02 06:17:00 28 4
gpt4 key购买 nike

我正在尝试使用 Dozer 映射两个类。但每次我输入映射类的方法时,都会引发以下错误:

org.apache.commons.lang.ClassUtils.getClass(Ljava/lang/String;)

有人知道我错过了什么或做错了什么吗?

我在 src/main/resources 中创建了 dozerBeanMapping.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>

并且还在我的 pom.xml 中添加了以下依赖项:

<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>

我的类(class)的映射位置是:

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)

谢谢

最佳答案

它看起来确实像一个旧的 commons-lang 依赖项。您可以运行:

mvn dependency:tree

查看类路径上是否没有来自该库的其他 jar。如果同一库中有多个 jar(例如在不同版本中),JVM 可能会使用错误的类。

关于java - Dozer org.apache.commons.lang.ClassUtils.getClass(Ljava/lang/String;) 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21366639/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com