优化代码,解决已知问题。

This commit is contained in:
chenxudong 2025-04-30 14:42:12 +08:00
parent d2cf904327
commit 2cea8178ce
2 changed files with 7 additions and 2 deletions

View File

@ -18,6 +18,11 @@ public class DruidDataSourceConfig {
@ConfigurationProperties(prefix = "spring.datasource") @ConfigurationProperties(prefix = "spring.datasource")
@ConditionalOnProperty(name = "spring.datasource.type", havingValue = "com.alibaba.druid.pool.DruidDataSource") @ConditionalOnProperty(name = "spring.datasource.type", havingValue = "com.alibaba.druid.pool.DruidDataSource")
public DataSource druid() { public DataSource druid() {
return new DruidDataSource(); DruidDataSource druidDataSource = new DruidDataSource();
druidDataSource.setValidationQuery("SELECT 1"); // 关键配置
druidDataSource.setTestWhileIdle(true);
druidDataSource.setTimeBetweenEvictionRunsMillis(60000);
druidDataSource.setTestOnBorrow(false); // 禁用借出时检测
return druidDataSource;
} }
} }

View File

@ -675,7 +675,7 @@ public class CommonService {
fileName, fileName,
destPath, destPath,
strategyStr, strategyStr,
fileName + "." + suffix); finalEdFileInfo.getFileName() + "." + suffix);
return ElectromagneticResultUtil.success(Optional.ofNullable(finalEdFileInfo).map(EdFileInfo::getId).orElse("")); return ElectromagneticResultUtil.success(Optional.ofNullable(finalEdFileInfo).map(EdFileInfo::getId).orElse(""));
} }