rev:代码规范:去掉未使用的import与格式化
This commit is contained in:
@@ -34,7 +34,9 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
@Configuration
|
||||
@EnableWebMvc
|
||||
public class ConfigurerAdapter implements WebMvcConfigurer {
|
||||
/** 文件配置 */
|
||||
/**
|
||||
* 文件配置
|
||||
*/
|
||||
private final FileProperties properties;
|
||||
|
||||
public ConfigurerAdapter(FileProperties properties) {
|
||||
@@ -56,8 +58,8 @@ public class ConfigurerAdapter implements WebMvcConfigurer {
|
||||
@Override
|
||||
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
||||
FileProperties.ElPath path = properties.getPath();
|
||||
String avatarUtl = "file:" + path.getAvatar().replace("\\","/");
|
||||
String pathUtl = "file:" + path.getPath().replace("\\","/");
|
||||
String avatarUtl = "file:" + path.getAvatar().replace("\\", "/");
|
||||
String pathUtl = "file:" + path.getPath().replace("\\", "/");
|
||||
registry.addResourceHandler("/avatar/**").addResourceLocations(avatarUtl).setCachePeriod(0);
|
||||
registry.addResourceHandler("/file/**").addResourceLocations(pathUtl).setCachePeriod(0);
|
||||
registry.addResourceHandler("/**").addResourceLocations("classpath:/META-INF/resources/").setCachePeriod(0);
|
||||
|
||||
@@ -16,6 +16,9 @@ import java.util.List;
|
||||
/**
|
||||
* 处理前端和后端Long类型失去精度问题.
|
||||
* https://blog.51cto.com/u_15127549/3519757
|
||||
* <p>
|
||||
* 序列换成json时,将所有的long变成string
|
||||
* 因为js中得数字类型不能包含所有的java long值
|
||||
*//*
|
||||
|
||||
@Configuration
|
||||
@@ -28,9 +31,9 @@ public class CustomJsonConfiguration implements WebMvcConfigurer {
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
*/
|
||||
/**
|
||||
* 序列换成json时,将所有的long变成string
|
||||
* 因为js中得数字类型不能包含所有的java long值
|
||||
*//*
|
||||
* 序列换成json时,将所有的long变成string
|
||||
* 因为js中得数字类型不能包含所有的java long值
|
||||
*//*
|
||||
|
||||
SimpleModule simpleModule = new SimpleModule();
|
||||
simpleModule.addSerializer(Long.class, ToStringSerializer.instance);
|
||||
|
||||
@@ -8,18 +8,15 @@ import com.alibaba.druid.proxy.jdbc.ResultSetProxy;
|
||||
import com.alibaba.druid.proxy.jdbc.StatementProxy;
|
||||
import com.alibaba.druid.sql.SQLUtils;
|
||||
import com.alibaba.druid.util.JdbcUtils;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.mysql.cj.jdbc.result.ResultSetImpl;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.MDC;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/*
|
||||
* @author ZZQ
|
||||
@@ -47,9 +44,10 @@ public class DruidFilter extends FilterEventAdapter {
|
||||
String executeSql = sql;
|
||||
int count = 0;
|
||||
try {
|
||||
count=statement.getUpdateCount();
|
||||
}catch (Exception ex){ }
|
||||
if (StringUtils.isNotEmpty(traceId) && count>0) {
|
||||
count = statement.getUpdateCount();
|
||||
} catch (Exception ex) {
|
||||
}
|
||||
if (StringUtils.isNotEmpty(traceId) && count > 0) {
|
||||
if (size > 0) {
|
||||
Collection<JdbcParameter> values = statement.getParameters().values();
|
||||
List<Object> params = new ArrayList<>();
|
||||
@@ -62,12 +60,13 @@ public class DruidFilter extends FilterEventAdapter {
|
||||
}
|
||||
super.statementExecuteAfter(statement, sql, result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultSetProxy statement_getResultSet(FilterChain chain, StatementProxy statement) throws SQLException {
|
||||
ResultSetProxy rs = super.statement_getResultSet(chain, statement);
|
||||
String executeSql = statement.getLastExecuteSql();
|
||||
String traceId = MDC.get("traceId");
|
||||
if (StringUtils.isNotEmpty(traceId)){
|
||||
if (StringUtils.isNotEmpty(traceId)) {
|
||||
int result = 0;
|
||||
if (rs != null) {
|
||||
ResultSetImpl rss = rs.getResultSetRaw().unwrap(ResultSetImpl.class);
|
||||
@@ -75,7 +74,7 @@ public class DruidFilter extends FilterEventAdapter {
|
||||
}
|
||||
try {
|
||||
int size = statement.getParametersSize();
|
||||
if (size>0){
|
||||
if (size > 0) {
|
||||
Collection<JdbcParameter> values = statement.getParameters().values();
|
||||
List<Object> params = new ArrayList<>();
|
||||
for (JdbcParameter value : values) {
|
||||
@@ -83,16 +82,13 @@ public class DruidFilter extends FilterEventAdapter {
|
||||
}
|
||||
executeSql = SQLUtils.format(executeSql, JdbcUtils.MYSQL, params);
|
||||
}
|
||||
}catch (Exception ex){
|
||||
log.warn("[-SQL解析异常-][{}]",ex.getMessage());
|
||||
} catch (Exception ex) {
|
||||
log.warn("[-SQL解析异常-][{}]", ex.getMessage());
|
||||
}
|
||||
log.info("[----SQL----][select][执行结果:{}][ SQL: {} ]",result, executeSql);
|
||||
log.info("[----SQL----][select][执行结果:{}][ SQL: {} ]", result, executeSql);
|
||||
}
|
||||
return rs;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ public class WebMvcConfig extends WebMvcConfigurerAdapter {
|
||||
*/
|
||||
@Bean
|
||||
@Autowired
|
||||
public ConversionService getConversionService(StringConverter dateConverter){
|
||||
public ConversionService getConversionService(StringConverter dateConverter) {
|
||||
ConversionServiceFactoryBean factoryBean = new ConversionServiceFactoryBean();
|
||||
|
||||
Set<Converter> converters = new HashSet<Converter>();
|
||||
|
||||
@@ -31,9 +31,9 @@ import org.springframework.web.socket.server.standard.ServerEndpointExporter;
|
||||
@Configuration
|
||||
public class WebSocketConfig {
|
||||
|
||||
@Bean
|
||||
public ServerEndpointExporter serverEndpointExporter() {
|
||||
return new ServerEndpointExporter();
|
||||
}
|
||||
@Bean
|
||||
public ServerEndpointExporter serverEndpointExporter() {
|
||||
return new ServerEndpointExporter();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,8 +13,6 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.sql.DataSource;
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
|
||||
@EnableTransactionManagement
|
||||
@Configuration
|
||||
@@ -23,9 +21,10 @@ public class MybatisPlusConfig {
|
||||
|
||||
@Autowired
|
||||
DataSource dataSource;
|
||||
|
||||
/**
|
||||
* 新的分页插件,一缓和二缓遵循mybatis的规则,需要设置 MybatisConfiguration#useDeprecatedExecutor = false 避免缓存出现问题(该属性会在旧插件移除后一同移除)
|
||||
添加自增插件
|
||||
* 添加自增插件
|
||||
*/
|
||||
@Bean
|
||||
public MybatisPlusInterceptor mybatisPlusInterceptor() {
|
||||
@@ -40,9 +39,9 @@ public class MybatisPlusConfig {
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
public void datainnit(){
|
||||
public void datainnit() {
|
||||
String url = ((DruidDataSource) dataSource).getUrl();
|
||||
System.out.println("项目数据库地址:"+url);
|
||||
log.debug("项目数据库地址:{}",url);
|
||||
System.out.println("项目数据库地址:" + url);
|
||||
log.debug("项目数据库地址:{}", url);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ import java.util.concurrent.ThreadPoolExecutor;
|
||||
|
||||
/**
|
||||
* 异步任务线程池装配类
|
||||
*
|
||||
* @author https://juejin.im/entry/5abb8f6951882555677e9da2
|
||||
* @date 2019年10月31日15:06:18
|
||||
*/
|
||||
@@ -33,7 +34,9 @@ import java.util.concurrent.ThreadPoolExecutor;
|
||||
@Configuration
|
||||
public class AsyncTaskExecutePool implements AsyncConfigurer {
|
||||
|
||||
/** 注入配置类 */
|
||||
/**
|
||||
* 注入配置类
|
||||
*/
|
||||
private final AsyncTaskProperties config;
|
||||
|
||||
public AsyncTaskExecutePool(AsyncTaskProperties config) {
|
||||
@@ -63,8 +66,8 @@ public class AsyncTaskExecutePool implements AsyncConfigurer {
|
||||
@Override
|
||||
public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() {
|
||||
return (throwable, method, objects) -> {
|
||||
log.error("===="+throwable.getMessage()+"====", throwable);
|
||||
log.error("exception method:"+method.getName());
|
||||
log.error("====" + throwable.getMessage() + "====", throwable);
|
||||
log.error("exception method:" + method.getName());
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 线程池配置属性类
|
||||
*
|
||||
* @author https://juejin.im/entry/5abb8f6951882555677e9da2
|
||||
* @date 2019年10月31日14:58:18
|
||||
*/
|
||||
|
||||
@@ -22,6 +22,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
/**
|
||||
* 自定义线程名称
|
||||
*
|
||||
* @author Zheng Jie
|
||||
* @date 2019年10月31日17:49:55
|
||||
*/
|
||||
@@ -37,7 +38,7 @@ public class TheadFactoryName implements ThreadFactory {
|
||||
this("el-pool");
|
||||
}
|
||||
|
||||
private TheadFactoryName(String name){
|
||||
private TheadFactoryName(String name) {
|
||||
SecurityManager s = System.getSecurityManager();
|
||||
group = (s != null) ? s.getThreadGroup() :
|
||||
Thread.currentThread().getThreadGroup();
|
||||
@@ -50,7 +51,7 @@ public class TheadFactoryName implements ThreadFactory {
|
||||
public Thread newThread(Runnable r) {
|
||||
//此时线程的名字 就是 namePrefix + -thread- + 这个线程池中第几个执行的线程
|
||||
Thread t = new Thread(group, r,
|
||||
namePrefix + "-thread-"+threadNumber.getAndIncrement(),
|
||||
namePrefix + "-thread-" + threadNumber.getAndIncrement(),
|
||||
0);
|
||||
if (t.isDaemon()) {
|
||||
t.setDaemon(false);
|
||||
|
||||
@@ -24,12 +24,13 @@ import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* 用于获取自定义线程池
|
||||
*
|
||||
* @author Zheng Jie
|
||||
* @date 2019年10月31日18:16:47
|
||||
*/
|
||||
public class ThreadPoolExecutorUtil {
|
||||
|
||||
public static ThreadPoolExecutor getPoll(){
|
||||
public static ThreadPoolExecutor getPoll() {
|
||||
AsyncTaskProperties properties = SpringContextHolder.getBean(AsyncTaskProperties.class);
|
||||
return new ThreadPoolExecutor(
|
||||
properties.getCorePoolSize(),
|
||||
|
||||
Reference in New Issue
Block a user