diff --git a/opsli-api/pom.xml b/opsli-api/pom.xml
index 208948fc18b8ac1c9da802c0ba58118651a08b60..c51251fa95a4a0fc179834abc0b8e53eddb3e3c3 100644
--- a/opsli-api/pom.xml
+++ b/opsli-api/pom.xml
@@ -43,9 +43,9 @@
com.github.xiaoymin
knife4j-spring-boot-starter
- 2.0.5
+ ${knife4j.version}
-
\ No newline at end of file
+
diff --git a/opsli-base-support/opsli-core/pom.xml b/opsli-base-support/opsli-core/pom.xml
index 6b489e3b690ef47e87dc46328f785858fab03793..2771ce9798ae916eb5716fa29d6b9899a6d5addb 100644
--- a/opsli-base-support/opsli-core/pom.xml
+++ b/opsli-base-support/opsli-core/pom.xml
@@ -120,8 +120,9 @@
- com.github.pagehelper
- pagehelper-spring-boot-starter
+ org.opsliframework.boot
+ opsli-plugins-pagehelper
+ ${pagehelper.version}
diff --git a/opsli-base-support/opsli-core/src/main/java/org/opsli/core/autoconfigure/conf/SwaggerConfig.java b/opsli-base-support/opsli-core/src/main/java/org/opsli/core/autoconfigure/conf/SwaggerConfig.java
index f7a293c53709d9a94580bcd18d37556a2f44c9e4..15d40cb4cbef2a25c02749d5f4ea7e57f53ba7a8 100644
--- a/opsli-base-support/opsli-core/src/main/java/org/opsli/core/autoconfigure/conf/SwaggerConfig.java
+++ b/opsli-base-support/opsli-core/src/main/java/org/opsli/core/autoconfigure/conf/SwaggerConfig.java
@@ -21,10 +21,14 @@ import com.google.common.collect.Lists;
import io.swagger.annotations.ApiOperation;
import org.opsli.core.autoconfigure.properties.GlobalProperties;
import org.opsli.core.utils.UserTokenUtil;
+import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
+import org.springframework.util.ReflectionUtils;
+import org.springframework.web.servlet.mvc.method.RequestMappingInfoHandlerMapping;
import springfox.bean.validators.configuration.BeanValidatorPluginsConfiguration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.ParameterBuilder;
@@ -35,10 +39,14 @@ import springfox.documentation.service.*;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spi.service.contexts.SecurityContext;
import springfox.documentation.spring.web.plugins.Docket;
+import springfox.documentation.spring.web.plugins.WebFluxRequestHandlerProvider;
+import springfox.documentation.spring.web.plugins.WebMvcRequestHandlerProvider;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
import javax.annotation.Resource;
+import java.lang.reflect.Field;
import java.util.List;
+import java.util.stream.Collectors;
/**
* Swagger 配置类
@@ -151,4 +159,41 @@ public class SwaggerConfig {
return new ApiKey(UserTokenUtil.TOKEN_NAME, UserTokenUtil.TOKEN_NAME, "header");
}
+ /**
+ * 解决springboot2.6 和springfox不兼容问题
+ * @return
+ */
+ @Bean
+ public static BeanPostProcessor springfoxHandlerProviderBeanPostProcessor() {
+ return new BeanPostProcessor() {
+
+ @Override
+ public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
+ if (bean instanceof WebMvcRequestHandlerProvider || bean instanceof WebFluxRequestHandlerProvider) {
+ customizeSpringfoxHandlerMappings(getHandlerMappings(bean));
+ }
+ return bean;
+ }
+
+ private void customizeSpringfoxHandlerMappings(List mappings) {
+ List copy = mappings.stream()
+ .filter(mapping -> mapping.getPatternParser() == null)
+ .collect(Collectors.toList());
+ mappings.clear();
+ mappings.addAll(copy);
+ }
+
+ @SuppressWarnings("unchecked")
+ private List getHandlerMappings(Object bean) {
+ try {
+ Field field = ReflectionUtils.findField(bean.getClass(), "handlerMappings");
+ field.setAccessible(true);
+ return (List) field.get(bean);
+ } catch (IllegalArgumentException | IllegalAccessException e) {
+ throw new IllegalStateException(e);
+ }
+ }
+ };
+ }
+
}
diff --git a/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/modulars/generator/importable/service/MySQLDatabaseTableServiceImpl.java b/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/modulars/generator/importable/service/MySQLDatabaseTableServiceImpl.java
index 9035a749f61b20f72809a0c1a44f0de373b0e255..02e57454178925c8710d0c21002fa23366ec7acc 100644
--- a/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/modulars/generator/importable/service/MySQLDatabaseTableServiceImpl.java
+++ b/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/modulars/generator/importable/service/MySQLDatabaseTableServiceImpl.java
@@ -24,6 +24,7 @@ import org.opsli.modulars.generator.importable.entity.DatabaseTable;
import org.opsli.modulars.generator.importable.mapper.MySQLDatabaseTableMapper;
import org.opsli.modulars.generator.table.service.IGenTableService;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import java.util.List;
@@ -50,6 +51,7 @@ public class MySQLDatabaseTableServiceImpl implements DatabaseTableService {
@Autowired(required = false)
private MySQLDatabaseTableMapper mapper;
+ @Lazy
@Autowired
private IGenTableService iGenTableService;
diff --git a/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/modulars/generator/logs/service/impl/GenLogsServiceImpl.java b/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/modulars/generator/logs/service/impl/GenLogsServiceImpl.java
index 3f02b35c617a54cd2d1486ecf5c006c6892e1af5..c8a3b3b3cfc249969534e478be10c85a7032ab39 100644
--- a/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/modulars/generator/logs/service/impl/GenLogsServiceImpl.java
+++ b/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/modulars/generator/logs/service/impl/GenLogsServiceImpl.java
@@ -40,6 +40,7 @@ import org.opsli.modulars.generator.table.service.IGenTableService;
import org.opsli.modulars.generator.table.wrapper.GenTableAndColumnModel;
import org.opsli.modulars.generator.table.wrapper.GenTableModel;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -53,6 +54,7 @@ import java.util.List;
* @author parker
* @date 2020-09-16 17:34
*/
+@Lazy(false)
@Service
public class GenLogsServiceImpl extends CrudServiceImpl
implements IGenLogsService {
diff --git a/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/modulars/generator/table/service/impl/GenTableServiceImpl.java b/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/modulars/generator/table/service/impl/GenTableServiceImpl.java
index 040bb898aae91c1c544020d1340aee6fb854daa1..91a5a4ef0d07d65b5edfd0da1b550e9b820c5d58 100644
--- a/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/modulars/generator/table/service/impl/GenTableServiceImpl.java
+++ b/opsli-modulars/opsli-modulars-generator/src/main/java/org/opsli/modulars/generator/table/service/impl/GenTableServiceImpl.java
@@ -37,6 +37,7 @@ import org.opsli.modulars.generator.table.service.IGenTableService;
import org.opsli.modulars.generator.table.wrapper.GenTableAndColumnModel;
import org.opsli.modulars.generator.table.wrapper.GenTableModel;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -57,9 +58,11 @@ public class GenTableServiceImpl extends CrudServiceImpl
+
+
+ opsli-plugins
+ org.opsliframework.boot
+ 1.0.0
+
+ 4.0.0
+
+ 1.4.6
+ opsli-plugins-pagehelper
+
+
+ 5.3.2
+ 2.2.2
+
+
+
+
+ org.mybatis
+ mybatis
+ compile
+
+
+
+ com.github.pagehelper
+ pagehelper
+ ${pagehelper.version}
+
+
+ org.mybatis.spring.boot
+ mybatis-spring-boot-autoconfigure
+ ${mybatis-spring-boot.version}
+
+
+ org.mybatis.spring.boot
+ mybatis-spring-boot-starter
+ ${mybatis-spring-boot.version}
+
+
+
+
+ org.springframework.boot
+ spring-boot-autoconfigure
+
+
+
+
+
diff --git a/opsli-plugins/opsli-plugins-pagehelper/src/main/java/org/opsli/plugins/pagehelper/PageHelperAutoConfiguration.java b/opsli-plugins/opsli-plugins-pagehelper/src/main/java/org/opsli/plugins/pagehelper/PageHelperAutoConfiguration.java
new file mode 100644
index 0000000000000000000000000000000000000000..10eef9dd317c683c8dfadef9a83a675d5890feff
--- /dev/null
+++ b/opsli-plugins/opsli-plugins-pagehelper/src/main/java/org/opsli/plugins/pagehelper/PageHelperAutoConfiguration.java
@@ -0,0 +1,69 @@
+package org.opsli.plugins.pagehelper;
+
+import com.github.pagehelper.PageInterceptor;
+import org.apache.ibatis.plugin.Interceptor;
+import org.apache.ibatis.session.SqlSessionFactory;
+import org.mybatis.spring.boot.autoconfigure.MybatisAutoConfiguration;
+import org.springframework.beans.factory.InitializingBean;
+import org.springframework.boot.autoconfigure.AutoConfigureAfter;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
+import org.springframework.boot.context.properties.EnableConfigurationProperties;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Lazy;
+
+import java.util.List;
+
+/**
+ * 自定注入分页插件
+ *
+ * @author liuzh
+ */
+@Configuration
+@ConditionalOnBean(SqlSessionFactory.class)
+@EnableConfigurationProperties(PageHelperProperties.class)
+@AutoConfigureAfter(MybatisAutoConfiguration.class)
+@Lazy(false)
+public class PageHelperAutoConfiguration implements InitializingBean {
+
+ private final List sqlSessionFactoryList;
+
+ private final PageHelperProperties properties;
+
+ public PageHelperAutoConfiguration(List sqlSessionFactoryList, PageHelperProperties properties) {
+ this.sqlSessionFactoryList = sqlSessionFactoryList;
+ this.properties = properties;
+ }
+
+ @Override
+ public void afterPropertiesSet() {
+ // 关闭 Banner
+ String bannerFlag = Boolean.TRUE.equals(this.properties.getBanner())?"true":"false";
+ System.setProperty("pagehelper.banner", bannerFlag);
+
+ PageInterceptor interceptor = new PageInterceptor();
+ interceptor.setProperties(this.properties);
+ for (SqlSessionFactory sqlSessionFactory : sqlSessionFactoryList) {
+ org.apache.ibatis.session.Configuration configuration = sqlSessionFactory.getConfiguration();
+ if (!containsInterceptor(configuration, interceptor)) {
+ configuration.addInterceptor(interceptor);
+ }
+ }
+ }
+
+ /**
+ * 是否已经存在相同的拦截器
+ *
+ * @param configuration
+ * @param interceptor
+ * @return
+ */
+ private boolean containsInterceptor(org.apache.ibatis.session.Configuration configuration, Interceptor interceptor) {
+ try {
+ // getInterceptors since 3.2.2
+ return configuration.getInterceptors().contains(interceptor);
+ } catch (Exception e) {
+ return false;
+ }
+ }
+
+}
diff --git a/opsli-plugins/opsli-plugins-pagehelper/src/main/java/org/opsli/plugins/pagehelper/PageHelperProperties.java b/opsli-plugins/opsli-plugins-pagehelper/src/main/java/org/opsli/plugins/pagehelper/PageHelperProperties.java
new file mode 100644
index 0000000000000000000000000000000000000000..fbe56e8a513feb878e522b915a6fbed1741837da
--- /dev/null
+++ b/opsli-plugins/opsli-plugins-pagehelper/src/main/java/org/opsli/plugins/pagehelper/PageHelperProperties.java
@@ -0,0 +1,135 @@
+package org.opsli.plugins.pagehelper;
+
+import org.springframework.boot.context.properties.ConfigurationProperties;
+
+import java.util.Properties;
+
+/**
+ * Configuration properties for PageHelper.
+ *
+ * @author liuzh
+ */
+@ConfigurationProperties(prefix = PageHelperProperties.PAGEHELPER_PREFIX)
+public class PageHelperProperties extends Properties {
+
+ public static final String PAGEHELPER_PREFIX = "pagehelper";
+
+ public Boolean getOffsetAsPageNum() {
+ return Boolean.valueOf(getProperty("offsetAsPageNum"));
+ }
+
+ public void setOffsetAsPageNum(Boolean offsetAsPageNum) {
+ setProperty("offsetAsPageNum", offsetAsPageNum.toString());
+ }
+
+ public Boolean getRowBoundsWithCount() {
+ return Boolean.valueOf(getProperty("rowBoundsWithCount"));
+ }
+
+ public void setRowBoundsWithCount(Boolean rowBoundsWithCount) {
+ setProperty("rowBoundsWithCount", rowBoundsWithCount.toString());
+ }
+
+ public Boolean getPageSizeZero() {
+ return Boolean.valueOf(getProperty("pageSizeZero"));
+ }
+
+ public void setPageSizeZero(Boolean pageSizeZero) {
+ setProperty("pageSizeZero", pageSizeZero.toString());
+ }
+
+ public Boolean getReasonable() {
+ return Boolean.valueOf(getProperty("reasonable"));
+ }
+
+ public void setReasonable(Boolean reasonable) {
+ setProperty("reasonable", reasonable.toString());
+ }
+
+ public Boolean getSupportMethodsArguments() {
+ return Boolean.valueOf(getProperty("supportMethodsArguments"));
+ }
+
+ public void setSupportMethodsArguments(Boolean supportMethodsArguments) {
+ setProperty("supportMethodsArguments", supportMethodsArguments.toString());
+ }
+
+ public String getDialect() {
+ return getProperty("dialect");
+ }
+
+ public void setDialect(String dialect) {
+ setProperty("dialect", dialect);
+ }
+
+ public String getHelperDialect() {
+ return getProperty("helperDialect");
+ }
+
+ public void setHelperDialect(String helperDialect) {
+ setProperty("helperDialect", helperDialect);
+ }
+
+ public Boolean getAutoRuntimeDialect() {
+ return Boolean.valueOf(getProperty("autoRuntimeDialect"));
+ }
+
+ public void setAutoRuntimeDialect(Boolean autoRuntimeDialect) {
+ setProperty("autoRuntimeDialect", autoRuntimeDialect.toString());
+ }
+
+ public Boolean getAutoDialect() {
+ return Boolean.valueOf(getProperty("autoDialect"));
+ }
+
+ public void setAutoDialect(Boolean autoDialect) {
+ setProperty("autoDialect", autoDialect.toString());
+ }
+
+ public Boolean getCloseConn() {
+ return Boolean.valueOf(getProperty("closeConn"));
+ }
+
+ public void setCloseConn(Boolean closeConn) {
+ setProperty("closeConn", closeConn.toString());
+ }
+
+ public String getParams() {
+ return getProperty("params");
+ }
+
+ public void setParams(String params) {
+ setProperty("params", params);
+ }
+
+ public Boolean getDefaultCount() {
+ return Boolean.valueOf(getProperty("defaultCount"));
+ }
+
+ public void setDefaultCount(Boolean defaultCount) {
+ setProperty("defaultCount", defaultCount.toString());
+ }
+
+ public String getDialectAlias() {
+ return getProperty("dialectAlias");
+ }
+
+ public void setDialectAlias(String dialectAlias) {
+ setProperty("dialectAlias", dialectAlias);
+ }
+
+ public String getAutoDialectClass() {
+ return getProperty("autoDialectClass");
+ }
+
+ public void setAutoDialectClass(String autoDialectClass) {
+ setProperty("autoDialectClass", autoDialectClass);
+ }
+
+ public Boolean getBanner() {
+ return Boolean.valueOf(getProperty("banner"));
+ }
+ public void setBanner(Boolean banner) {
+ setProperty("banner", banner.toString());
+ }
+}
diff --git a/opsli-plugins/opsli-plugins-pagehelper/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/opsli-plugins/opsli-plugins-pagehelper/src/main/resources/META-INF/additional-spring-configuration-metadata.json
new file mode 100644
index 0000000000000000000000000000000000000000..052b40961a492b2b40a5bec6f25cd5467fc4f2a4
--- /dev/null
+++ b/opsli-plugins/opsli-plugins-pagehelper/src/main/resources/META-INF/additional-spring-configuration-metadata.json
@@ -0,0 +1,88 @@
+{
+ "groups": [
+ {
+ "name": "pagehelper",
+ "type": "org.opsli.plugins.pagehelper.PageHelperProperties",
+ "sourceType": "org.opsli.plugins.pagehelper.PageHelperProperties"
+ }
+ ],
+ "properties": [
+ {
+ "name": "pagehelper.banner",
+ "type": "java.lang.Boolean",
+ "defaultValue": false,
+ "sourceType": "org.opsli.plugins.pagehelper.PageHelperProperties"
+ },
+ {
+ "name": "pagehelper.auto-dialect",
+ "type": "java.lang.Boolean",
+ "sourceType": "org.opsli.plugins.pagehelper.PageHelperProperties"
+ },
+ {
+ "name": "pagehelper.auto-dialect-class",
+ "type": "java.lang.String",
+ "sourceType": "org.opsli.plugins.pagehelper.PageHelperProperties"
+ },
+ {
+ "name": "pagehelper.auto-runtime-dialect",
+ "type": "java.lang.Boolean",
+ "sourceType": "org.opsli.plugins.pagehelper.PageHelperProperties"
+ },
+ {
+ "name": "pagehelper.close-conn",
+ "type": "java.lang.Boolean",
+ "sourceType": "org.opsli.plugins.pagehelper.PageHelperProperties"
+ },
+ {
+ "name": "pagehelper.default-count",
+ "type": "java.lang.Boolean",
+ "sourceType": "org.opsli.plugins.pagehelper.PageHelperProperties"
+ },
+ {
+ "name": "pagehelper.dialect",
+ "type": "java.lang.String",
+ "sourceType": "org.opsli.plugins.pagehelper.PageHelperProperties"
+ },
+ {
+ "name": "pagehelper.dialect-alias",
+ "type": "java.lang.String",
+ "sourceType": "org.opsli.plugins.pagehelper.PageHelperProperties"
+ },
+ {
+ "name": "pagehelper.helper-dialect",
+ "type": "java.lang.String",
+ "sourceType": "org.opsli.plugins.pagehelper.PageHelperProperties"
+ },
+ {
+ "name": "pagehelper.offset-as-page-num",
+ "type": "java.lang.Boolean",
+ "sourceType": "org.opsli.plugins.pagehelper.PageHelperProperties"
+ },
+ {
+ "name": "pagehelper.page-size-zero",
+ "type": "java.lang.Boolean",
+ "sourceType": "org.opsli.plugins.pagehelper.PageHelperProperties"
+ },
+ {
+ "name": "pagehelper.params",
+ "type": "java.lang.String",
+ "sourceType": "org.opsli.plugins.pagehelper.PageHelperProperties"
+ },
+ {
+ "name": "pagehelper.reasonable",
+ "type": "java.lang.Boolean",
+ "sourceType": "org.opsli.plugins.pagehelper.PageHelperProperties"
+ },
+ {
+ "name": "pagehelper.row-bounds-with-count",
+ "type": "java.lang.Boolean",
+ "sourceType": "org.opsli.plugins.pagehelper.PageHelperProperties"
+ },
+ {
+ "name": "pagehelper.support-methods-arguments",
+ "type": "java.lang.Boolean",
+ "sourceType": "org.opsli.plugins.pagehelper.PageHelperProperties"
+ }
+ ],
+ "hints": []
+}
diff --git a/opsli-plugins/opsli-plugins-pagehelper/src/main/resources/META-INF/spring.factories b/opsli-plugins/opsli-plugins-pagehelper/src/main/resources/META-INF/spring.factories
new file mode 100644
index 0000000000000000000000000000000000000000..330be8e6fe5889293791bde1398a68da7129b24e
--- /dev/null
+++ b/opsli-plugins/opsli-plugins-pagehelper/src/main/resources/META-INF/spring.factories
@@ -0,0 +1,3 @@
+# Auto Configure
+org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
+org.opsli.plugins.pagehelper.PageHelperAutoConfiguration
diff --git a/opsli-plugins/pom.xml b/opsli-plugins/pom.xml
index 922805695eb39cf52c74f63b817fcd94074c37ac..d898af7f695913b31d793622d1dbdc0884097a03 100644
--- a/opsli-plugins/pom.xml
+++ b/opsli-plugins/pom.xml
@@ -25,6 +25,7 @@
opsli-plugins-email
opsli-plugins-sms
opsli-plugins-security
+ opsli-plugins-pagehelper
diff --git a/opsli-starter/src/main/resources/application.yaml b/opsli-starter/src/main/resources/application.yaml
index 098d489a6c497d7897f1f045e87cbdb0601ed864..283a11e3641f1fbefd871478b260b0018821a253 100644
--- a/opsli-starter/src/main/resources/application.yaml
+++ b/opsli-starter/src/main/resources/application.yaml
@@ -36,8 +36,6 @@ spring:
max-file-size: 10MB
max-request-size: 10MB
#静态资源
- resources:
- static-locations: classpath:/META-INF/resources/,classpath:/resources/, classpath:/static/, classpath:/public/,file:${opsli.web.upload-path}
#json 时间戳统一转换
jackson:
date-format: yyyy-MM-dd HH:mm:ss
@@ -52,7 +50,13 @@ spring:
#
#main:
# allow-bean-definition-overriding: true
-
+ web:
+ resources:
+ static-locations: classpath:/META-INF/resources/,classpath:/resources/, classpath:/static/, classpath:/public/,file:${opsli.web.upload-path}
+ mvc:
+ #Spring Boot 2.6+后映射匹配的默认策略已从AntPathMatcher更改为PathPatternParser,需要手动指定为ant-path-matcher
+ pathmatch:
+ matching-strategy: ant_path_matcher
# 缓存配置项
cache:
# 前缀
diff --git a/pom.xml b/pom.xml
index 7f207d9185b6b5f57c6982e19473f927140cd4fe..d09f3758e1d6e65ec3ad1d006a3e01008a81054f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -34,7 +34,7 @@
org.springframework.boot
spring-boot-starter-parent
- 2.5.6
+ 2.7.10
@@ -59,12 +59,15 @@
UTF-8
UTF-8
1.8
- 2.5.6
+
+ 2.7.10
true
1.2.83
+ 3.5.9
3.5.2
- 1.3.0
+ 1.4.6
+ 3.0.3
3.10.3
5.6.1
@@ -169,19 +172,17 @@
+
+ org.mybatis
+ mybatis
+ ${mybatis.version}
+
com.baomidou
mybatis-plus-boot-starter
${mybatis-plus.version}
-
-
- com.github.pagehelper
- pagehelper-spring-boot-starter
- ${pagehelper.version}
-
-
com.alibaba