目录
1.启动错误
1.1 错误: 找不到或无法加载主类
解决方法:
mvn clean package
1.2 找不到主清单
在CCE容器部署时候发现日志一直打印这个,然后容器无法正常启动
no main manifest attribute, in delivery-ocpx-1.0.0.jar
问题原因:注意repackage
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.6.6</version>
<configuration>
<fork>true</fork> <!-- 如果没有该配置,devtools不会生效 -->
</configuration>
<!-- 加上这个就ok了 -->
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
2.找不到类
2.1 java -jar 启动失败
问题描述:IDEA可以正常启动,打包后运行出现java.lang.ClassNotFoundException
详细:
为什么我能搞出这么大的BUG
问题原因:
解决方法:
3.定时任务
问题描述:
1.通过@Scheduler启动的定时任务在本地执行,服务器部署也执行,但是在docker容器中不执行
问题原因:
1.这个定时任务是单线程,需要配置任务线程池
@Bean
public TaskScheduler taskScheduler() {
ThreadPoolTaskScheduler taskScheduler = new ThreadPoolTaskScheduler();
taskScheduler.setPoolSize(50);
return taskScheduler;
}
2.时区问题,本地时区和容器的时区不一样
@Scheduled(cron = "0 0/1 * * * ?", zone = "Asia/Shanghai")
时区问题在使用@Scheduled注解时保持和docker容器里面的时区一致
然后问题解决
4.AOP和JetCache同时使用出现的问题
java.lang.IllegalStateException: No MethodInvocation found: Check that an AOP invocation is in progress and that the ExposeInvocationInterceptor is upfront in the interceptor chain. Specifically, note that advices with order HIGHEST_PRECEDENCE will execute before ExposeInvocationInterceptor! In addition, ExposeInvocationInterceptor and ExposeInvocationInterceptor.currentInvocation() must be invoked from the same thread
解决办法:加入 @Order注解