Commit 183bb5855ab47231821125b774468a4dfa430a56
1 parent
8e21b520
解决 db doc 导出的报错问题
Showing
4 changed files
with
20 additions
and
105 deletions
ruoyi-common/src/main/java/com/ruoyi/common/config/ResourcesConfig.java
| @@ -20,19 +20,10 @@ import com.ruoyi.framework.interceptor.RepeatSubmitInterceptor; | @@ -20,19 +20,10 @@ import com.ruoyi.framework.interceptor.RepeatSubmitInterceptor; | ||
| 20 | */ | 20 | */ |
| 21 | @Configuration | 21 | @Configuration |
| 22 | public class ResourcesConfig implements WebMvcConfigurer { | 22 | public class ResourcesConfig implements WebMvcConfigurer { |
| 23 | + | ||
| 23 | @Autowired | 24 | @Autowired |
| 24 | private RepeatSubmitInterceptor repeatSubmitInterceptor; | 25 | private RepeatSubmitInterceptor repeatSubmitInterceptor; |
| 25 | 26 | ||
| 26 | - @Override | ||
| 27 | - public void addResourceHandlers(ResourceHandlerRegistry registry) { | ||
| 28 | - /** 本地文件上传路径 */ | ||
| 29 | - registry.addResourceHandler(Constants.RESOURCE_PREFIX + "/**").addResourceLocations("file:" + RuoYiConfig.getProfile() + "/"); | ||
| 30 | - | ||
| 31 | - /** swagger配置 */ | ||
| 32 | - registry.addResourceHandler("swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/"); | ||
| 33 | - registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/"); | ||
| 34 | - } | ||
| 35 | - | ||
| 36 | /** | 27 | /** |
| 37 | * 自定义拦截规则 | 28 | * 自定义拦截规则 |
| 38 | */ | 29 | */ |
ruoyi-common/src/main/java/com/ruoyi/common/config/properties/DruidProperties.java deleted
| 1 | -package com.ruoyi.framework.config.properties; | ||
| 2 | - | ||
| 3 | -import org.springframework.beans.factory.annotation.Value; | ||
| 4 | -import org.springframework.context.annotation.Configuration; | ||
| 5 | -import com.alibaba.druid.pool.DruidDataSource; | ||
| 6 | - | ||
| 7 | -/** | ||
| 8 | - * druid 配置属性 | ||
| 9 | - * | ||
| 10 | - * @author ruoyi | ||
| 11 | - */ | ||
| 12 | -@Configuration | ||
| 13 | -public class DruidProperties { | ||
| 14 | - @Value("${spring.datasource.druid.initialSize}") | ||
| 15 | - private int initialSize; | ||
| 16 | - | ||
| 17 | - @Value("${spring.datasource.druid.minIdle}") | ||
| 18 | - private int minIdle; | ||
| 19 | - | ||
| 20 | - @Value("${spring.datasource.druid.maxActive}") | ||
| 21 | - private int maxActive; | ||
| 22 | - | ||
| 23 | - @Value("${spring.datasource.druid.maxWait}") | ||
| 24 | - private int maxWait; | ||
| 25 | - | ||
| 26 | - @Value("${spring.datasource.druid.timeBetweenEvictionRunsMillis}") | ||
| 27 | - private int timeBetweenEvictionRunsMillis; | ||
| 28 | - | ||
| 29 | - @Value("${spring.datasource.druid.minEvictableIdleTimeMillis}") | ||
| 30 | - private int minEvictableIdleTimeMillis; | ||
| 31 | - | ||
| 32 | - @Value("${spring.datasource.druid.maxEvictableIdleTimeMillis}") | ||
| 33 | - private int maxEvictableIdleTimeMillis; | ||
| 34 | - | ||
| 35 | - @Value("${spring.datasource.druid.validationQuery}") | ||
| 36 | - private String validationQuery; | ||
| 37 | - | ||
| 38 | - @Value("${spring.datasource.druid.testWhileIdle}") | ||
| 39 | - private boolean testWhileIdle; | ||
| 40 | - | ||
| 41 | - @Value("${spring.datasource.druid.testOnBorrow}") | ||
| 42 | - private boolean testOnBorrow; | ||
| 43 | - | ||
| 44 | - @Value("${spring.datasource.druid.testOnReturn}") | ||
| 45 | - private boolean testOnReturn; | ||
| 46 | - | ||
| 47 | - public DruidDataSource dataSource(DruidDataSource datasource) { | ||
| 48 | - /** 配置初始化大小、最小、最大 */ | ||
| 49 | - datasource.setInitialSize(initialSize); | ||
| 50 | - datasource.setMaxActive(maxActive); | ||
| 51 | - datasource.setMinIdle(minIdle); | ||
| 52 | - | ||
| 53 | - /** 配置获取连接等待超时的时间 */ | ||
| 54 | - datasource.setMaxWait(maxWait); | ||
| 55 | - | ||
| 56 | - /** 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 */ | ||
| 57 | - datasource.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis); | ||
| 58 | - | ||
| 59 | - /** 配置一个连接在池中最小、最大生存的时间,单位是毫秒 */ | ||
| 60 | - datasource.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis); | ||
| 61 | - datasource.setMaxEvictableIdleTimeMillis(maxEvictableIdleTimeMillis); | ||
| 62 | - | ||
| 63 | - /** | ||
| 64 | - * 用来检测连接是否有效的sql,要求是一个查询语句,常用select 'x'。如果validationQuery为null,testOnBorrow、testOnReturn、testWhileIdle都不会起作用。 | ||
| 65 | - */ | ||
| 66 | - datasource.setValidationQuery(validationQuery); | ||
| 67 | - /** 建议配置为true,不影响性能,并且保证安全性。申请连接的时候检测,如果空闲时间大于timeBetweenEvictionRunsMillis,执行validationQuery检测连接是否有效。 */ | ||
| 68 | - datasource.setTestWhileIdle(testWhileIdle); | ||
| 69 | - /** 申请连接时执行validationQuery检测连接是否有效,做了这个配置会降低性能。 */ | ||
| 70 | - datasource.setTestOnBorrow(testOnBorrow); | ||
| 71 | - /** 归还连接时执行validationQuery检测连接是否有效,做了这个配置会降低性能。 */ | ||
| 72 | - datasource.setTestOnReturn(testOnReturn); | ||
| 73 | - return datasource; | ||
| 74 | - } | ||
| 75 | -} |
src/main/java/cn/iocoder/dashboard/modules/infra/controller/doc/InfDbDocController.java
| @@ -44,28 +44,31 @@ public class InfDbDocController { | @@ -44,28 +44,31 @@ public class InfDbDocController { | ||
| 44 | 44 | ||
| 45 | @GetMapping("/export-html") | 45 | @GetMapping("/export-html") |
| 46 | public synchronized void exportHtml(HttpServletResponse response) throws FileNotFoundException { | 46 | public synchronized void exportHtml(HttpServletResponse response) throws FileNotFoundException { |
| 47 | - // 创建 screw 的配置 | ||
| 48 | - Configuration config = Configuration.builder() | ||
| 49 | - .version(DOC_VERSION) // 版本 | ||
| 50 | - .description(DOC_DESCRIPTION) // 描述 | ||
| 51 | - .dataSource(buildDataSource()) // 数据源 | ||
| 52 | - .engineConfig(buildEngineConfig()) // 引擎配置 | ||
| 53 | - .produceConfig(buildProcessConfig()) // 处理配置 | ||
| 54 | - .build(); | 47 | + try (HikariDataSource dataSource = buildDataSource()) { |
| 48 | + // 创建 screw 的配置 | ||
| 49 | + Configuration config = Configuration.builder() | ||
| 50 | + .version(DOC_VERSION) // 版本 | ||
| 51 | + .description(DOC_DESCRIPTION) // 描述 | ||
| 52 | + .dataSource(dataSource) // 数据源 | ||
| 53 | + .engineConfig(buildEngineConfig()) // 引擎配置 | ||
| 54 | + .produceConfig(buildProcessConfig()) // 处理配置 | ||
| 55 | + .build(); | ||
| 55 | 56 | ||
| 56 | - // 执行 screw,生成数据库文档 | ||
| 57 | - new DocumentationExecute(config).execute(); | 57 | + // 执行 screw,生成数据库文档 |
| 58 | + new DocumentationExecute(config).execute(); | ||
| 58 | 59 | ||
| 59 | - // 读取,返回 | ||
| 60 | - ServletUtil.write(response, | ||
| 61 | - new FileInputStream(FILE_OUTPUT_DIR + File.separator + DOC_FILE_NAME + FILE_OUTPUT_TYPE.getFileSuffix()), | ||
| 62 | - MediaType.TEXT_HTML_VALUE); | 60 | + // 读取,返回 |
| 61 | + ServletUtil.write(response, | ||
| 62 | + new FileInputStream(FILE_OUTPUT_DIR + File.separator + DOC_FILE_NAME + FILE_OUTPUT_TYPE.getFileSuffix()), | ||
| 63 | + MediaType.TEXT_HTML_VALUE); | ||
| 64 | + } | ||
| 63 | } | 65 | } |
| 64 | 66 | ||
| 65 | /** | 67 | /** |
| 66 | * 创建数据源 | 68 | * 创建数据源 |
| 67 | */ | 69 | */ |
| 68 | - private DataSource buildDataSource() { | 70 | + // TODO 芋艿:screw 暂时不支持 druid,尴尬 |
| 71 | + private HikariDataSource buildDataSource() { | ||
| 69 | // 创建 HikariConfig 配置类 | 72 | // 创建 HikariConfig 配置类 |
| 70 | HikariConfig hikariConfig = new HikariConfig(); | 73 | HikariConfig hikariConfig = new HikariConfig(); |
| 71 | // hikariConfig.setDriverClassName("com.mysql.cj.jdbc.Driver"); | 74 | // hikariConfig.setDriverClassName("com.mysql.cj.jdbc.Driver"); |
src/main/java/cn/iocoder/dashboard/modules/system/service/logger/impl/SysLoginLogServiceImpl.java
| @@ -5,10 +5,9 @@ import cn.iocoder.dashboard.modules.system.controller.logger.vo.loginlog.SysLogi | @@ -5,10 +5,9 @@ import cn.iocoder.dashboard.modules.system.controller.logger.vo.loginlog.SysLogi | ||
| 5 | import cn.iocoder.dashboard.modules.system.controller.logger.vo.loginlog.SysLoginLogExportReqVO; | 5 | import cn.iocoder.dashboard.modules.system.controller.logger.vo.loginlog.SysLoginLogExportReqVO; |
| 6 | import cn.iocoder.dashboard.modules.system.controller.logger.vo.loginlog.SysLoginLogPageReqVO; | 6 | import cn.iocoder.dashboard.modules.system.controller.logger.vo.loginlog.SysLoginLogPageReqVO; |
| 7 | import cn.iocoder.dashboard.modules.system.convert.logger.SysLoginLogConvert; | 7 | import cn.iocoder.dashboard.modules.system.convert.logger.SysLoginLogConvert; |
| 8 | -import cn.iocoder.dashboard.modules.system.dal.mysql.logger.SysLoginLogMapper; | ||
| 9 | import cn.iocoder.dashboard.modules.system.dal.dataobject.logger.SysLoginLogDO; | 8 | import cn.iocoder.dashboard.modules.system.dal.dataobject.logger.SysLoginLogDO; |
| 9 | +import cn.iocoder.dashboard.modules.system.dal.mysql.logger.SysLoginLogMapper; | ||
| 10 | import cn.iocoder.dashboard.modules.system.service.logger.SysLoginLogService; | 10 | import cn.iocoder.dashboard.modules.system.service.logger.SysLoginLogService; |
| 11 | -import cn.iocoder.dashboard.modules.system.service.user.SysUserService; | ||
| 12 | import org.springframework.stereotype.Service; | 11 | import org.springframework.stereotype.Service; |
| 13 | 12 | ||
| 14 | import javax.annotation.Resource; | 13 | import javax.annotation.Resource; |
| @@ -23,9 +22,6 @@ public class SysLoginLogServiceImpl implements SysLoginLogService { | @@ -23,9 +22,6 @@ public class SysLoginLogServiceImpl implements SysLoginLogService { | ||
| 23 | @Resource | 22 | @Resource |
| 24 | private SysLoginLogMapper loginLogMapper; | 23 | private SysLoginLogMapper loginLogMapper; |
| 25 | 24 | ||
| 26 | - @Resource | ||
| 27 | - private SysUserService userService; | ||
| 28 | - | ||
| 29 | @Override | 25 | @Override |
| 30 | public void createLoginLog(SysLoginLogCreateReqVO reqVO) { | 26 | public void createLoginLog(SysLoginLogCreateReqVO reqVO) { |
| 31 | SysLoginLogDO loginLog = SysLoginLogConvert.INSTANCE.convert(reqVO); | 27 | SysLoginLogDO loginLog = SysLoginLogConvert.INSTANCE.convert(reqVO); |