@RequestBody部分属性为null的问题
Controller方法中使用@RequestBody接收到的值为空?
关于Springboot | @RequestBody 接收到的参数对象属性为空的问题
解决异常报错java.sql.SQLException: Value '0000-00-00 00:00:00' can not be represented as java.sql.Timestamp
除了这种,还有别的类型,都可以归类为一种,就是处理myql字段,通常这种异常报错,copy相应的sql代码并不会出现什么问题,基本可以成功在直接数据库的操作中得到一个结果集,但是,系统会异常,因为字段类型和项目中返回数据集中某个字段类型不一致;
诸如这里是因为时间,存在时间类型的字段,为0000-00-00这个值没有意义,在正式库中不会出现,测试库中会有这个报错导致整个功能不能成功进行排查测试;按照上面的链接进行处理,目前,不成功;
但是因为是测试库数据不合理,所以我直接修改测试库数据内容即解决,解决方案治标不治本;
另一个问题是同样在测试过程中,数据查询一直报错,原因排查到是因为,数据库中a 字段为varchar字符串类型,但是实体类中为Integer类型,a数值通常为1,2,3,5这几个表示状态的数值,而且实体类是一个共用的返回类型,不能轻易更改类型,这里原系统有考虑到这个问题,直接在service中写了一个方法,先把a保存为另一个名称的字段,然后把这个字段用java代码使用数据字典这种类型的数据,进行获取具体的Integer类型字段,然后再对a字段赋值,保存,就没有问题了;
结论:
这种情况通常会是数据库操作没有问题,但是系统没办法成功运行,代码会报错;隐藏性比较高,容易找不到具体缘由;因此在此记录,避免浪费时间;
因为不知名原因,把UserService设置成一个模板类型,个人解决方案不同于参考链接,但性质一致;
如下图,最后在相应位置发现有UserService,这就是唯一创建UserService这个文件的原因了;
已解决;
Unable to parse template "Class" Error message: Selected class file name 'ProductServlet.java' mappe
设置成XX.vm的文件格式,然后记得apply,重新设置成中文不乱码模式,然后导出配置;
关于EasyCode模板配置以及一些问题的处理:
easycode使用碰到的问题以及自定义的模板
改模板仅供参考其中的中文内容部分,对照EasyCode中Default_SRM配置乱码部分;目前EasyCode配置已备份至20220331;可以成功生成mp结构,但是,配置本身的中文乱码,参照价值为零;
通常为当前项目启动同时有页面在运行,占用端口造成的(猜测)
解决 Disconnected from the target VM, address: ‘127.0.0.1:51458‘, transport: ‘socket‘
[ERROR] [Help 1] DependencyResolutionException - Apache Maven - Apache Software Foundation
参考的解决链接:bug:jar:1.0-SNAPSHOT is missing, no dependency information available
找到idea的右侧maven管理侧边栏,确定其中的root根文件目录,然后clean再install ; 而后可以执行对应的文件;
解决java.lang.IllegalStateException: Unable to find a @SpringBootConfiguration, you need to use
总结:单元测试的测试类一定要和启动类在同一个根目录下。
以下错误是从下往上进行记录的,最新的放在最前面,
以下一系列错误皆源自pom引入依赖导致依赖冲突形成的,解决方案是,把pom文件中原来的引入依赖变更为如下:增加了exclusions即可;
如何找到解决方案的:
复制其中一行错误提示,发现有回答和我使用场景非常相似,不出意外,的确如博主所说,为此类错误,之前百度的关键错误error code 并非切合实际,因此没有找到具体的解决方案;
com.alibaba
easyexcel
3.0.2
ehcache
org.ehcache
Caused by: java.lang.annotation.IncompleteAnnotationException: org.terracotta.statistics.Statistic missing element type
at sun.reflect.annotation.AnnotationInvocationHandler.invoke(AnnotationInvocationHandler.java:81)
at com.sun.proxy.$Proxy101.type(Unknown Source)
at org.terracotta.statistics.StatisticsManager.parseStatisticAnnotations(StatisticsManager.java:114)
at org.terracotta.context.ContextManager.contextCreated(ContextManager.java:183)
at org.terracotta.context.ContextManager.getOrCreateTreeNode(ContextManager.java:136)
at org.terracotta.context.ContextManager.associate(ContextManager.java:114)
at org.terracotta.context.ContextManager.access$000(ContextManager.java:38)
at org.terracotta.context.ContextManager$1.withChild(ContextManager.java:57)
at
... 104 common frames omitted
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [net.sf.ehcache.CacheManager]: Factory method 'ehCacheCacheManager' threw exception; nested exception is net.sf.ehcache.CacheException: java.lang.annotation.IncompleteAnnotationException: org.terracotta.statistics.Statistic missing element type at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185)
java.lang.IllegalStateException: The product Cache is not alive (STATUS_SHUTDOWN)
at net.sf.ehcache.Cache$CacheStatus.checkAlive(Cache.java:4108)
at net.sf.ehcache.Cache.checkStatus(Cache.java:2799)
at net.sf.ehcache.Cache.putInternal(Cache.java:1567)
at net.sf.ehcache.Cache.put(Cache.java:1543)
at net.sf.ehcache.Cache.put(Cache.java:1508)
at org.springframework.cache.ehcache.EhCacheCache.put(EhCacheCache.java:125)
at com.core.dic.DictLoad.loadData(DictLoad.java:50)
at com.core.dic.DictLoad$DicThread.run(DictLoad.java:69)
Disconnected from the target VM, address: '127.0.0.1:60926', transport: 'socket'
暂无
参考链接:HttpMessageNotReadableException错误
产生的原因有以下三种:
1.后端的实体类与前端的传入参数数据不一样,这时候我们可以通过检查前端传入的数据和后端接收的数据,进行比较,把他们改为相同即可。
2.我们使用@RequestBody注解,但是我们请求方式是get请求,这个时候我们要把get请求改为post请求,但是如果我们不想改动请求方式,坚持使用get请求的话,可以考虑使用@RequestParam和@PathVariable。
3.如果我们没有解决跨域问题的话,那么跨域问题也可能会导致该报错的产生,如果我们后端被@RequestBody修饰的参数实体类没有实现序列化接口,如果不序列化也会出错。
错误concole输出:
ERROR[http-nio-8089-exec-1] com.css.handler.GlobalDefultExceptionHandler(98)
Method:POST
Exception Type:org.springframework.http.converter.HttpMessageNotReadableException
Exception Details:
org.springframework.http.converter.HttpMessageNotReadableException: Required request body is missing: public void com.css.controller.refund.RefundBillContorller.refundBillExcelOut(com.alibaba.fastjson.JSONObject,javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse) throws java.io.IOException
at org.springframework.web.servlet.mvc.method.annotation.RequestResponseBodyMethodProcessor.readWithMessageConverters(RequestResponseBodyMethodProcessor.java:161)
at org.springframework.web.servlet.mvc.method.annotation.RequestResponseBodyMethodProcessor.resolveArgument(RequestResponseBodyMethodProcessor.java:130)
at org.springframework.web.method.support.HandlerMethodArgumentResolverComposite.resolveArgument(HandlerMethodArgumentResolverComposite.java:124)
at org.springframework.web.method.support.InvocableHandlerMethod.getMethodArgumentValues(InvocableHandlerMethod.java:161)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:131)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:102)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:870)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:776)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:991)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:925)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:978)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:881)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:661)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:855)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:109)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:81)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:200)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:496)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:803)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:790)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1459)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)
查询接口在apifox中测试,前提是故意不登录,会Response一个具体的错误,包括not login,不会产生异常报错;
同样接查询接口进行同样内容的导出,报如下异常错误,但不会返not login的错误提示。代码的权限校验方式一致,返回设计一致,但是返回不一致;
【****】[****] ERROR[http-nio-8089-exec-10] com.css.handler.GlobalDefultExceptionHandler(98)
---Exception Log Begin---
url:http://127.0.0.1:808*/**/refundBillExcelOut
Method:POST
Exception Type:java.lang.NullPointerException
Exception Details:
java.lang.NullPointerException: null
使用Java中的JSch转发端口时,“本地端口...无法绑定”
pom添加相关依赖;
mysqlUtil中添加连接的方法和变量,封装调用的方法便于整体的调用;
添加JeCommon适配css原系统的连接数据库的方式,结合yml配置文件以及MyUtil中方法