问题描述
严重:Servlet.service()forservlet[springmvc]incontextwithpath[/]threwexception[Handlerprocessingfailed;nestedexceptionisjava.lang.NoSuchMethodError:net.shopxx.entity.Product.setTempPrice(Ljava/math/BigDecimal;)V]withrootcausejava.lang.NoSuchMethodError:net.shopxx.entity.Product.setTempPrice(Ljava/math/BigDecimal;)Vatnet.shopxx.service.impl.SearchServiceImpl.searchProduct(SearchServiceImpl.java:339)atsun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethod)atsun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)atsun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)atjava.lang.reflect.Method.invoke(Method.java:597)atorg.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)atorg.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)atorg.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)atorg.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:96)atorg.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:260)atorg.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:94)atorg.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)atorg.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)at$Proxy99.searchProduct(UnknownSource)atnet.shopxx.controller.shop.SearchController.search(SearchController.java:74)atsun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethod)atsun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)atsun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)atjava.lang.reflect.Method.invoke(Method.java:597)atorg.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:219)atorg.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132)atorg.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104)atorg.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:745)atorg.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:686)atorg.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)atorg.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:925)atorg.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)atorg.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:936)atorg.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:827)atjavax.servlet.http.HttpServlet.service(HttpServlet.java:621)atorg.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:812)atjavax.servlet.http.HttpServlet.service(HttpServlet.java:728)atorg.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)atorg.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)atcom.planetj.servlet.filter.compression.CompressingFilter.doFilter(CompressingFilter.java:270)atorg.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)atorg.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)atnet.shopxx.filter.SiteStatusFilter.doFilterInternal(SiteStatusFilter.java:50)atorg.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)atorg.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)atorg.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)atorg.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)atorg.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)atorg.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)atorg.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)atorg.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)atorg.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)atorg.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)atorg.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)atorg.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)atorg.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)atorg.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)atorg.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:936)atorg.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)atorg.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)atorg.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)atorg.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)atorg.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)atjava.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)atjava.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)atjava.lang.Thread.run(Thread.java:619)
解决方案
解决方案二:
在线等,第二天上班就弄这个bug弄了一天,今天又继续弄。。
解决方案三:
你配置文件中也加入TempPrice这个。
解决方案四:
引用2楼rui888的回复:
你配置文件中也加入TempPrice这个。
用的注解,怎么破。。找不到配置文件
解决方案五:
我又在表中添加了temp_price字段,还是不能用get/set方法/***获取临时商品价格**@return临时商品价格*/@JsonProperty@Field(store=Store.YES,index=Index.UN_TOKENIZED)@NumericField@FieldBridge(impl=BigDecimalNumericFieldBridge.class)@NotNull@Min(0)@Digits(integer=12,fraction=3)@Column(name="temp_prcice",nullable=false,precision=19,scale=2)publicBigDecimalgetTempPrice(){returntempPrice;}/***设置临时商品价格**@paramtimePrice*临时商品价格*/publicvoidsetTempPrice(BigDecimaltempPrice){this.tempPrice=tempPrice;}
解决方案六:
求大神,在线急等。。
解决方案七:
jpa标准有setter,getter都是映射到数据库的,如果自己加其他的属性,要使用@Transient注解。
解决方案八:
参数异常,封装不了肯定报错!
解决方案九:
引用6楼yys79的回复:
jpa标准有setter,getter都是映射到数据库的,如果自己加其他的属性,要使用@Transient注解。
正解,@Transient属性就是非数据库映射字段,楼主可以看看Hibernate注解的说明文档,写的非常清楚啊。。。