12月 132019
 

问题与原因

启动spring boot程序时,报异常,导致程序启动失败,遇到形如下面的错误:

A child container failed during start
java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat].StandardHost[localhost].StandardContext[/Integration]]
at java.util.concurrent.FutureTask.report(FutureTask.java:122)
at java.util.concurrent.FutureTask.get(FutureTask.java:192)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1123)
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:800)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
……

然而,这个只是结果,实际上并不能定位问题,笔者继续找异常,看到类似下面的错误: Continue reading »

11月 242019
 

现象

spring boot 启动时,连接mysql 8数据库报错errorCode 0, state 08001

原因

1. spring boot项目中,pom文件中配置的mysql驱动版本与mysql数据库版本不一致

此时修改pom文件中的版本即可,可以使用下面的配置:

……
<groupId>mysql
<artifactId>mysql-connector-java</artifactId>
<version>8.0.11</version>
……

同时,yml文件中的mysql驱动类文件最好修改成

……
driver-class-name: com.mysql.cj.jdbc.Driver
……

Continue reading »

11月 242019
 

问题

导入excel文件时,偶发bug:

org.springframework.web.multipart.MultipartException: Could not parse multipart servlet request; nested exception is java.io.IOException: The temporary upload location [C:\Users\AppData\Local\Temp\tomcat.4266029690466887869.8037\work\Tomcat\localhost\ROOT] is not valid
	at org.springframework.web.multipart.support.StandardMultipartHttpServletRequest.parseRequest(StandardMultipartHttpServletRequest.java:112)
	at org.springframework.web.multipart.support.StandardMultipartHttpServletRequest.<init>(StandardMultipartHttpServletRequest.java:86)
	at org.springframework.web.multipart.support.StandardServletMultipartResolver.resolveMultipart(StandardServletMultipartResolver.java:79)
	at org.springframework.web.servlet.DispatcherServlet.checkMultipart(DispatcherServlet.java:1104)
	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:936)
	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:901)
	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
	at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:661)
	at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)

原因

Spring boot项目在导入文件时,没有找到指定文件夹。
子所以是偶发的问题,是因为spring boot项目本身在启动后会自动在Temp文件夹中创建若干临时文件夹,而操作系统可能会定期删除这些临时文件夹。linux也有类似操作系统自动清空临时文件夹的操作,参见这篇文章CentOS7的/tmp目录自动清理规则

 
Continue reading »

9月 052019
 

问题

spring boot + spring cloud,上传附件时遇到如下错误:

org.springframework.web.multipart.MultipartException: Could not parse multipart servlet request; nested exception is java.lang.IllegalStateException: org.apache.tomcat.util.http.fileupload.FileUploadBase$SizeLimitExceededException: the request was rejected because its size (11963927) exceeds the configured maximum (10485760)

错误信息表示上传附件报超出自带tomacat限制大小(默认1M)
Continue reading »