1.jeeplus框架启动报错
报错:
org.springframework.data.redis.serializer.SerializationException: Cannot deserialize; nested exception is org.springframework.core.serializer.support.SerializationFailedException: Failed to deserialize payload. Is the byte array a result of corresponding serialization for DefaultDeserializer?; nested exception is java.io.InvalidClassException: com.jeeplus.sys.service.dto.UserDTO; incompatible types for field isAdmin
解决:
用another redis工具删除Redis中记录
2.跨域问题
添加文件
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
import org.springframework.web.filter.CorsFilter;
@Configuration
public class MyCorsConfig {
private CorsConfiguration corsConfig() {
CorsConfiguration corsConfiguration = new CorsConfiguration();
corsConfiguration.addAllowedOriginPattern("*");
corsConfiguration.addAllowedHeader("*");
corsConfiguration.addAllowedMethod("*");
corsConfiguration.setAllowCredentials(true);
corsConfiguration.setMaxAge(3600L);
return corsConfiguration;
}
@Bean
public CorsFilter corsFilter() {
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
source.registerCorsConfiguration("/**", corsConfig());
return new CorsFilter(source);
}
}
3.定时器只执行第一次或者不执行
定时器类:
方法上注解 @Scheduled(cron = "0 0/5 * * * ?")
类上注解: @Component
主启动类注解: @EnableScheduling
采用定时线程池:
先在主启动类中加载线程池,再在定时任务加注解,选择对应的线程池名称
@Async(value = "taskThreadPoolExecutor")
****************************************************************
程序加载只执行一次或者不执行,加定时器多线程配置:
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.SchedulingConfigurer;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
import org.springframework.scheduling.config.ScheduledTaskRegistrar;
import java.util.concurrent.ScheduledThreadPoolExecutor;
/**
* 定时器多线程配置
* @author lu
* @date 2022年08月12日 13:43
*/
@Configuration
public class ScheduleConfig implements SchedulingConfigurer {
// @Override
// public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
// ThreadPoolTaskScheduler taskScheduler = new ThreadPoolTaskScheduler();
// taskScheduler.setPoolSize(10);
// taskScheduler.initialize();
// taskRegistrar.setTaskScheduler(taskScheduler);
// }
@Override
public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
taskRegistrar.setScheduler(new ScheduledThreadPoolExecutor(Runtime.getRuntime().availableProcessors(),
r -> new Thread(r,"my-schedule")));
}
}
4.http get请求,传值时间参数yyyy-MM-dd HH:mm:ss,有空格,400
URLEncoder.encode("timestamp","utf-8")
将该参数转码放置
5.不在GROUP BY子句中,包含非聚合列'某参数',该列在功能上不依赖于GROUP BY子句中的列;这与sql_mode=only_full_group_by不兼容
select 查询参数不在group by中的,将该查询参数改为:any_value(a.deve_code) as deve_code