与Ruoyi-SpringBoot3做兼容
This commit is contained in:
parent
1a17dd3e5d
commit
47e8fc9ae8
38
pom.xml
38
pom.xml
@ -10,12 +10,6 @@
|
|||||||
<name>ruoyi</name>
|
<name>ruoyi</name>
|
||||||
<url>http://www.ruoyi.vip</url>
|
<url>http://www.ruoyi.vip</url>
|
||||||
<description>若依管理系统</description>
|
<description>若依管理系统</description>
|
||||||
<parent>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-parent</artifactId>
|
|
||||||
<version>3.0.0</version>
|
|
||||||
<relativePath/>
|
|
||||||
</parent>
|
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<ruoyi.version>3.8.5.3</ruoyi.version>
|
<ruoyi.version>3.8.5.3</ruoyi.version>
|
||||||
@ -36,18 +30,21 @@
|
|||||||
<velocity.version>2.3</velocity.version>
|
<velocity.version>2.3</velocity.version>
|
||||||
<jwt.version>0.9.1</jwt.version>
|
<jwt.version>0.9.1</jwt.version>
|
||||||
<knife4j.version>4.3.0</knife4j.version>
|
<knife4j.version>4.3.0</knife4j.version>
|
||||||
|
<mybatis-spring-boot.version>3.0.2</mybatis-spring-boot.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
|
|
||||||
<!-- 依赖声明 -->
|
<!-- 依赖声明 -->
|
||||||
<dependencyManagement>
|
<dependencyManagement>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<!-- servlet包 -->
|
<!-- spring-boot版本2.5.15更换为3.1.5 -->
|
||||||
<!-- <dependency>-->
|
<dependency>
|
||||||
<!-- <groupId>javax.servlet</groupId>-->
|
<groupId>org.springframework.boot</groupId>
|
||||||
<!-- <artifactId>javax.servlet-api</artifactId>-->
|
<artifactId>spring-boot-dependencies</artifactId>
|
||||||
<!-- <version>4.0.1</version>-->
|
<version>3.1.5</version>
|
||||||
<!-- </dependency>-->
|
<type>pom</type>
|
||||||
|
<scope>import</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>javax.xml.bind</groupId>
|
<groupId>javax.xml.bind</groupId>
|
||||||
@ -55,20 +52,11 @@
|
|||||||
<version>2.3.1</version>
|
<version>2.3.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- SpringBoot的依赖配置-->
|
|
||||||
<!-- <dependency>-->
|
|
||||||
<!-- <groupId>org.springframework.boot</groupId>-->
|
|
||||||
<!-- <artifactId>spring-boot-dependencies</artifactId>-->
|
|
||||||
<!-- <version>2.7.14</version>-->
|
|
||||||
<!-- <type>pom</type>-->
|
|
||||||
<!-- <scope>import</scope>-->
|
|
||||||
<!-- </dependency>-->
|
|
||||||
|
|
||||||
<!-- Mysql驱动包 -->
|
<!-- Mysql驱动包 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.mysql</groupId>
|
<groupId>com.mysql</groupId>
|
||||||
<artifactId>mysql-connector-j</artifactId>
|
<artifactId>mysql-connector-j</artifactId>
|
||||||
<version>8.0.33</version>
|
<version>8.1.0</version>
|
||||||
<scope>runtime</scope>
|
<scope>runtime</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
@ -197,6 +185,12 @@
|
|||||||
<version>${ruoyi.version}</version>
|
<version>${ruoyi.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>jakarta.servlet</groupId>
|
||||||
|
<artifactId>jakarta.servlet-api</artifactId>
|
||||||
|
<version>6.0.0</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- knife4j -->
|
<!-- knife4j -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.xiaoymin</groupId>
|
<groupId>com.github.xiaoymin</groupId>
|
||||||
|
@ -15,6 +15,12 @@
|
|||||||
</description>
|
</description>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<!-- 注入冲突 -->
|
||||||
|
<!-- <dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||||
|
</dependency> -->
|
||||||
|
|
||||||
|
|
||||||
<!-- spring-boot-devtools -->
|
<!-- spring-boot-devtools -->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -30,8 +30,7 @@ import com.ruoyi.framework.datasource.DynamicDataSource;
|
|||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
@Configuration
|
@Configuration
|
||||||
public class DruidConfig
|
public class DruidConfig {
|
||||||
{
|
|
||||||
@Bean
|
@Bean
|
||||||
public DruidStatProperties druidStatProperties() {
|
public DruidStatProperties druidStatProperties() {
|
||||||
return new DruidStatProperties();
|
return new DruidStatProperties();
|
||||||
@ -39,8 +38,7 @@ public class DruidConfig
|
|||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@ConfigurationProperties("spring.datasource.druid.master")
|
@ConfigurationProperties("spring.datasource.druid.master")
|
||||||
public DataSource masterDataSource(DruidProperties druidProperties)
|
public DataSource masterDataSource(DruidProperties druidProperties) {
|
||||||
{
|
|
||||||
DruidDataSource dataSource = DruidDataSourceBuilder.create().build();
|
DruidDataSource dataSource = DruidDataSourceBuilder.create().build();
|
||||||
return druidProperties.dataSource(dataSource);
|
return druidProperties.dataSource(dataSource);
|
||||||
}
|
}
|
||||||
@ -48,16 +46,14 @@ public class DruidConfig
|
|||||||
@Bean
|
@Bean
|
||||||
@ConfigurationProperties("spring.datasource.druid.slave")
|
@ConfigurationProperties("spring.datasource.druid.slave")
|
||||||
@ConditionalOnProperty(prefix = "spring.datasource.druid.slave", name = "enabled", havingValue = "true")
|
@ConditionalOnProperty(prefix = "spring.datasource.druid.slave", name = "enabled", havingValue = "true")
|
||||||
public DataSource slaveDataSource(DruidProperties druidProperties)
|
public DataSource slaveDataSource(DruidProperties druidProperties) {
|
||||||
{
|
|
||||||
DruidDataSource dataSource = DruidDataSourceBuilder.create().build();
|
DruidDataSource dataSource = DruidDataSourceBuilder.create().build();
|
||||||
return druidProperties.dataSource(dataSource);
|
return druidProperties.dataSource(dataSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean(name = "dynamicDataSource")
|
@Bean(name = "dynamicDataSource")
|
||||||
@Primary
|
@Primary
|
||||||
public DynamicDataSource dataSource(DataSource masterDataSource)
|
public DynamicDataSource dataSource(DataSource masterDataSource) {
|
||||||
{
|
|
||||||
Map<Object, Object> targetDataSources = new HashMap<>();
|
Map<Object, Object> targetDataSources = new HashMap<>();
|
||||||
targetDataSources.put(DataSourceType.MASTER.name(), masterDataSource);
|
targetDataSources.put(DataSourceType.MASTER.name(), masterDataSource);
|
||||||
setDataSource(targetDataSources, DataSourceType.SLAVE.name(), "slaveDataSource");
|
setDataSource(targetDataSources, DataSourceType.SLAVE.name(), "slaveDataSource");
|
||||||
@ -68,18 +64,14 @@ public class DruidConfig
|
|||||||
* 设置数据源
|
* 设置数据源
|
||||||
*
|
*
|
||||||
* @param targetDataSources 备选数据源集合
|
* @param targetDataSources 备选数据源集合
|
||||||
* @param sourceName 数据源名称
|
* @param sourceName 数据源名称
|
||||||
* @param beanName bean名称
|
* @param beanName bean名称
|
||||||
*/
|
*/
|
||||||
public void setDataSource(Map<Object, Object> targetDataSources, String sourceName, String beanName)
|
public void setDataSource(Map<Object, Object> targetDataSources, String sourceName, String beanName) {
|
||||||
{
|
try {
|
||||||
try
|
|
||||||
{
|
|
||||||
DataSource dataSource = SpringUtils.getBean(beanName);
|
DataSource dataSource = SpringUtils.getBean(beanName);
|
||||||
targetDataSources.put(sourceName, dataSource);
|
targetDataSources.put(sourceName, dataSource);
|
||||||
}
|
} catch (Exception e) {
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,8 +81,7 @@ public class DruidConfig
|
|||||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||||
@Bean
|
@Bean
|
||||||
@ConditionalOnProperty(name = "spring.datasource.druid.statViewServlet.enabled", havingValue = "true")
|
@ConditionalOnProperty(name = "spring.datasource.druid.statViewServlet.enabled", havingValue = "true")
|
||||||
public FilterRegistrationBean removeDruidFilterRegistrationBean(DruidStatProperties properties)
|
public FilterRegistrationBean removeDruidFilterRegistrationBean(DruidStatProperties properties) {
|
||||||
{
|
|
||||||
// 获取web监控页面的参数
|
// 获取web监控页面的参数
|
||||||
DruidStatProperties.StatViewServlet config = properties.getStatViewServlet();
|
DruidStatProperties.StatViewServlet config = properties.getStatViewServlet();
|
||||||
// 提取common.js的配置路径
|
// 提取common.js的配置路径
|
||||||
@ -98,16 +89,14 @@ public class DruidConfig
|
|||||||
String commonJsPattern = pattern.replaceAll("\\*", "js/common.js");
|
String commonJsPattern = pattern.replaceAll("\\*", "js/common.js");
|
||||||
final String filePath = "support/http/resources/js/common.js";
|
final String filePath = "support/http/resources/js/common.js";
|
||||||
// 创建filter进行过滤
|
// 创建filter进行过滤
|
||||||
Filter filter = new Filter()
|
Filter filter = new Filter() {
|
||||||
{
|
|
||||||
@Override
|
@Override
|
||||||
public void init(jakarta.servlet.FilterConfig filterConfig) throws ServletException
|
public void init(jakarta.servlet.FilterConfig filterConfig) throws ServletException {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
|
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
|
||||||
throws IOException, ServletException
|
throws IOException, ServletException {
|
||||||
{
|
|
||||||
chain.doFilter(request, response);
|
chain.doFilter(request, response);
|
||||||
// 重置缓冲区,响应头不会被重置
|
// 重置缓冲区,响应头不会被重置
|
||||||
response.resetBuffer();
|
response.resetBuffer();
|
||||||
@ -118,9 +107,9 @@ public class DruidConfig
|
|||||||
text = text.replaceAll("powered.*?shrek.wang</a>", "");
|
text = text.replaceAll("powered.*?shrek.wang</a>", "");
|
||||||
response.getWriter().write(text);
|
response.getWriter().write(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void destroy()
|
public void destroy() {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
FilterRegistrationBean registrationBean = new FilterRegistrationBean();
|
FilterRegistrationBean registrationBean = new FilterRegistrationBean();
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.ruoyi.framework.config;
|
package com.ruoyi.framework.config;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.http.HttpMethod;
|
import org.springframework.http.HttpMethod;
|
||||||
|
@ -45,13 +45,15 @@ public class PermitAllUrlProperties implements InitializingBean, ApplicationCont
|
|||||||
|
|
||||||
// 获取方法上边的注解 替代path variable 为 *
|
// 获取方法上边的注解 替代path variable 为 *
|
||||||
Anonymous method = AnnotationUtils.findAnnotation(handlerMethod.getMethod(), Anonymous.class);
|
Anonymous method = AnnotationUtils.findAnnotation(handlerMethod.getMethod(), Anonymous.class);
|
||||||
Optional.ofNullable(method).ifPresent(anonymous -> Objects.requireNonNull(info.getPatternsCondition().getPatterns())
|
Optional.ofNullable(method)
|
||||||
.forEach(url -> urls.add(RegExUtils.replaceAll(url, PATTERN, ASTERISK))));
|
.ifPresent(anonymous -> Objects.requireNonNull(info.getPathPatternsCondition().getPatternValues()) //
|
||||||
|
.forEach(url -> urls.add(RegExUtils.replaceAll(url, PATTERN, ASTERISK))));
|
||||||
|
|
||||||
// 获取类上边的注解, 替代path variable 为 *
|
// 获取类上边的注解, 替代path variable 为 *
|
||||||
Anonymous controller = AnnotationUtils.findAnnotation(handlerMethod.getBeanType(), Anonymous.class);
|
Anonymous controller = AnnotationUtils.findAnnotation(handlerMethod.getBeanType(), Anonymous.class);
|
||||||
Optional.ofNullable(controller).ifPresent(anonymous -> Objects.requireNonNull(info.getPatternsCondition().getPatterns())
|
Optional.ofNullable(controller)
|
||||||
.forEach(url -> urls.add(RegExUtils.replaceAll(url, PATTERN, ASTERISK))));
|
.ifPresent(anonymous -> Objects.requireNonNull(info.getPathPatternsCondition().getPatternValues())
|
||||||
|
.forEach(url -> urls.add(RegExUtils.replaceAll(url, PATTERN, ASTERISK))));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user