refactor: 升级 springboot 版本.

This commit is contained in:
lijiahangmax
2023-12-28 00:26:46 +08:00
parent dae142e434
commit 47657da24d
18 changed files with 218 additions and 45 deletions

View File

@@ -15,23 +15,24 @@
<properties>
<revision>1.0.0</revision>
<spring.boot.version>2.7.11</spring.boot.version>
<spring.boot.version>2.7.17</spring.boot.version>
<spring.boot.admin.version>2.7.15</spring.boot.admin.version>
<flatten.maven.plugin.version>1.5.0</flatten.maven.plugin.version>
<orion.kit.revision>1.0.6</orion.kit.revision>
<aspectj.version>1.9.7</aspectj.version>
<lombok.version>1.18.26</lombok.version>
<springdoc.version>1.6.15</springdoc.version>
<knife4j.version>4.1.0</knife4j.version>
<mapstruct.version>1.5.5.Final</mapstruct.version>
<mybatis-plus.version>3.5.3.1</mybatis-plus.version>
<mybatis-plus-generator.version>3.5.3.1</mybatis-plus-generator.version>
<mybatis-plus-join.version>1.4.6</mybatis-plus-join.version>
<mybatis.plus.version>3.5.3.1</mybatis.plus.version>
<mybatis.plus.generator.version>3.5.3.1</mybatis.plus.generator.version>
<mybatis.plus.join.version>1.4.6</mybatis.plus.join.version>
<velocity.version>2.3</velocity.version>
<druid.version>1.2.16</druid.version>
<redisson.version>3.18.0</redisson.version>
<spring-boot-admin.version>2.7.10</spring-boot-admin.version>
<transmittable-thread-local.version>2.14.2</transmittable-thread-local.version>
<mockito-inline.version>4.11.0</mockito-inline.version>
<jedis-mock.version>1.0.7</jedis-mock.version>
<transmittable.thread.local.version>2.14.2</transmittable.thread.local.version>
<mockito.inline.version>4.11.0</mockito.inline.version>
<jedis.mock.version>1.0.7</jedis.mock.version>
<podam.version>7.2.11.RELEASE</podam.version>
</properties>
@@ -203,12 +204,12 @@
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>${mybatis-plus.version}</version>
<version>${mybatis.plus.version}</version>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-generator</artifactId>
<version>${mybatis-plus-generator.version}</version>
<version>${mybatis.plus.generator.version}</version>
</dependency>
<dependency>
<groupId>org.apache.velocity</groupId>
@@ -218,7 +219,7 @@
<dependency>
<groupId>com.github.yulichang</groupId>
<artifactId>mybatis-plus-join-boot-starter</artifactId>
<version>${mybatis-plus-join.version}</version>
<version>${mybatis.plus.join.version}</version>
</dependency>
<!-- redis -->
@@ -245,19 +246,19 @@
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-server</artifactId>
<version>${spring-boot-admin.version}</version>
<version>${spring.boot.admin.version}</version>
</dependency>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-client</artifactId>
<version>${spring-boot-admin.version}</version>
<version>${spring.boot.admin.version}</version>
</dependency>
<!-- transmittable -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>transmittable-thread-local</artifactId>
<version>${transmittable-thread-local.version}</version>
<version>${transmittable.thread.local.version}</version>
</dependency>
<!-- test -->
@@ -285,14 +286,14 @@
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-inline</artifactId>
<version>${mockito-inline.version}</version>
<version>${mockito.inline.version}</version>
</dependency>
<!-- test redis -->
<dependency>
<groupId>com.github.fppt</groupId>
<artifactId>jedis-mock</artifactId>
<version>${jedis-mock.version}</version>
<version>${jedis.mock.version}</version>
</dependency>
<!-- test entity 随机生成器 -->
@@ -304,4 +305,35 @@
</dependencies>
</dependencyManagement>
<build>
<plugins>
<!-- 统一 revision 版本 -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>flatten-maven-plugin</artifactId>
<version>${flatten.maven.plugin.version}</version>
<configuration>
<flattenMode>resolveCiFriendliesOnly</flattenMode>
<updatePomFile>true</updatePomFile>
</configuration>
<executions>
<execution>
<goals>
<goal>flatten</goal>
</goals>
<id>flatten</id>
<phase>process-resources</phase>
</execution>
<execution>
<goals>
<goal>clean</goal>
</goals>
<id>flatten.clean</id>
<phase>clean</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@@ -15,7 +15,7 @@ public class WebsocketAuthorizeRequestsCustomizer extends AuthorizeRequestsCusto
@Override
public void customize(ExpressionUrlAuthorizationConfigurer<HttpSecurity>.ExpressionInterceptUrlRegistry registry) {
// websocket 允许匿名访问
registry.antMatchers("/keep-alive/**").permitAll();
registry.antMatchers("/orion/keep-alive/**").permitAll();
}
}

View File

@@ -39,7 +39,7 @@ import java.util.Optional;
*/
@Profile({"dev"})
@ConditionalOnClass({OpenAPI.class})
@EnableConfigurationProperties(SwaggerProperties.class)
@EnableConfigurationProperties(SwaggerConfig.class)
@ConditionalOnProperty(prefix = "springdoc.api-docs", name = "enabled", havingValue = "true", matchIfMissing = true)
@AutoConfiguration
@AutoConfigureOrder(AutoConfigureOrderConst.FRAMEWORK_SWAGGER)
@@ -53,7 +53,7 @@ public class OrionSwaggerAutoConfiguration {
* @return OpenAPI
*/
@Bean
public OpenAPI openApi(SwaggerProperties properties) {
public OpenAPI openApi(SwaggerConfig properties) {
Map<String, SecurityScheme> securitySchemas = this.buildSecuritySchemes();
OpenAPI api = new OpenAPI()
// 接口信息
@@ -68,7 +68,7 @@ public class OrionSwaggerAutoConfiguration {
/**
* api 摘要信息
*/
private Info buildInfo(SwaggerProperties properties) {
private Info buildInfo(SwaggerConfig properties) {
return new Info()
.title(properties.getTitle())
.description(properties.getDescription())
@@ -117,7 +117,7 @@ public class OrionSwaggerAutoConfiguration {
*/
@Bean
public GroupedOpenApi allGroupedOpenApi(ConfigurableListableBeanFactory beanFactory,
SwaggerProperties properties) {
SwaggerConfig properties) {
// 全部
GroupedOpenApi all = this.buildGroupedOpenApi("全部", "*");
// 注册模块分组 api

View File

@@ -6,13 +6,15 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
import java.util.Map;
/**
* swagger 配置
*
* @author Jiahang Li
* @version 1.0.0
* @since 2023/6/21 11:13
*/
@Data
@ConfigurationProperties("orion.swagger")
public class SwaggerProperties {
public class SwaggerConfig {
/**
* 标题

View File

@@ -2,8 +2,8 @@
"groups": [
{
"name": "orion.swagger",
"type": "com.orion.ops.framework.swagger.config.SwaggerProperties",
"sourceType": "com.orion.ops.framework.swagger.config.SwaggerProperties"
"type": "com.orion.ops.framework.swagger.config.SwaggerConfig",
"sourceType": "com.orion.ops.framework.swagger.config.SwaggerConfig"
}
],
"properties": [

View File

@@ -1,8 +1,7 @@
package com.orion.ops.framework.websocket.config;
import com.orion.ops.framework.common.constant.AutoConfigureOrderConst;
import com.orion.ops.framework.websocket.core.WebsocketContainerConfig;
import com.orion.ops.framework.websocket.interceptor.UserHandshakeInterceptor;
import com.orion.ops.framework.websocket.core.interceptor.UserHandshakeInterceptor;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.AutoConfigureOrder;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
@@ -21,14 +20,14 @@ import org.springframework.web.socket.server.standard.ServletServerContainerFact
@EnableWebSocket
@AutoConfiguration
@AutoConfigureOrder(AutoConfigureOrderConst.FRAMEWORK_WEBSOCKET)
@EnableConfigurationProperties(WebsocketContainerConfig.class)
@EnableConfigurationProperties(WebsocketConfig.class)
public class OrionWebsocketAutoConfiguration {
/**
* @return websocket 缓冲区大小配置
*/
@Bean
public ServletServerContainerFactoryBean servletServerContainerFactoryBean(WebsocketContainerConfig config) {
public ServletServerContainerFactoryBean servletServerContainerFactoryBean(WebsocketConfig config) {
ServletServerContainerFactoryBean factory = new ServletServerContainerFactoryBean();
factory.setMaxBinaryMessageBufferSize(config.getBinaryBufferSize());
factory.setMaxTextMessageBufferSize(config.getBinaryBufferSize());

View File

@@ -1,4 +1,4 @@
package com.orion.ops.framework.websocket.core;
package com.orion.ops.framework.websocket.config;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
@@ -12,7 +12,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
*/
@Data
@ConfigurationProperties("spring.websocket")
public class WebsocketContainerConfig {
public class WebsocketConfig {
/**
* 二进制消息缓冲区大小 byte

View File

@@ -1,4 +1,4 @@
package com.orion.ops.framework.websocket.constant;
package com.orion.ops.framework.websocket.core.constant;
import lombok.AllArgsConstructor;
import lombok.Getter;

View File

@@ -1,4 +1,4 @@
package com.orion.ops.framework.websocket.constant;
package com.orion.ops.framework.websocket.core.constant;
import com.orion.lang.utils.Exceptions;
import com.orion.lang.utils.Strings;

View File

@@ -1,7 +1,7 @@
package com.orion.ops.framework.websocket.interceptor;
package com.orion.ops.framework.websocket.core.interceptor;
import com.orion.ops.framework.common.security.SecurityHolder;
import com.orion.ops.framework.websocket.constant.WsAttr;
import com.orion.ops.framework.websocket.core.constant.WsAttr;
import org.springframework.http.server.ServerHttpRequest;
import org.springframework.http.server.ServerHttpResponse;
import org.springframework.web.socket.WebSocketHandler;

View File

@@ -1,4 +1,4 @@
package com.orion.ops.framework.websocket.utils;
package com.orion.ops.framework.websocket.core.utils;
import com.orion.lang.exception.AuthenticationException;
import com.orion.lang.exception.ConnectionRuntimeException;
@@ -6,7 +6,7 @@ import com.orion.lang.exception.DisabledException;
import com.orion.lang.exception.TimeoutException;
import com.orion.lang.utils.Exceptions;
import com.orion.lang.utils.Urls;
import com.orion.ops.framework.websocket.constant.WsCloseCode;
import com.orion.ops.framework.websocket.core.constant.WsCloseCode;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.server.ServerHttpRequest;
import org.springframework.web.socket.CloseStatus;

View File

@@ -115,7 +115,7 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<!-- 如果 spring.boot.version 版本修改, 则这里也要跟着修改 -->
<version>2.7.11</version>
<version>2.7.17</version>
<configuration>
<fork>true</fork>
</configuration>

View File

@@ -41,6 +41,12 @@
<artifactId>orion-ops-spring-boot-starter-web</artifactId>
</dependency>
<!-- web-socket -->
<dependency>
<groupId>com.orion.ops</groupId>
<artifactId>orion-ops-spring-boot-starter-websocket</artifactId>
</dependency>
<!-- log -->
<dependency>
<groupId>com.orion.ops</groupId>

View File

@@ -0,0 +1,63 @@
package com.orion.ops.module.asset.interceptor;
import com.orion.ops.framework.websocket.core.interceptor.UserHandshakeInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
import org.springframework.web.socket.*;
import org.springframework.web.socket.config.annotation.WebSocketConfigurer;
import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry;
import org.springframework.web.socket.handler.TextWebSocketHandler;
import javax.annotation.Resource;
/**
* @author Jiahang Li
* @version 1.0.0
* @since 2023/12/27 23:53
*/
@Configuration
public class TerminalInterceptor implements WebSocketConfigurer {
// https://blog.csdn.net/oNew_Lifeo/article/details/130003676
// https://wstool.js.org/
@Resource
private UserHandshakeInterceptor userHandshakeInterceptor;
@Override
public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
registry.addHandler(new WebSocketHandler1(), "/orion/keep-alive/host/terminal")
.addInterceptors(userHandshakeInterceptor)
.setAllowedOrigins("*");
System.out.println("123");
}
static class WebSocketHandler1 implements WebSocketHandler {
@Override
public void afterConnectionEstablished(WebSocketSession session) throws Exception {
System.out.println(1);
}
@Override
public void handleMessage(WebSocketSession session, WebSocketMessage<?> message) throws Exception {
System.out.println(message);
}
@Override
public void handleTransportError(WebSocketSession session, Throwable exception) throws Exception {
System.out.println(1);
}
@Override
public void afterConnectionClosed(WebSocketSession session, CloseStatus closeStatus) throws Exception {
System.out.println(1);
}
@Override
public boolean supportsPartialMessages() {
return false;
}
}
}

View File

@@ -0,0 +1,37 @@
package com.orion.ops.module.asset.interceptor;
import com.orion.ops.framework.websocket.core.interceptor.UserHandshakeInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
import org.springframework.web.socket.TextMessage;
import org.springframework.web.socket.WebSocketSession;
import org.springframework.web.socket.config.annotation.WebSocketConfigurer;
import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry;
import org.springframework.web.socket.handler.TextWebSocketHandler;
import javax.annotation.Resource;
/**
* @author Jiahang Li
* @version 1.0.0
* @since 2023/12/27 23:53
*/
// @Configuration
public class TerminalInterceptor1 implements WebSocketConfigurer {
@Resource
private UserHandshakeInterceptor userHandshakeInterceptor;
@Override
public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
registry.addHandler(new TextWebSocketHandler() {
@Override
protected void handleTextMessage(WebSocketSession session, TextMessage message) throws Exception {
System.out.println(message);
}
}, "/orion/keep-alive/host/terminal1")
.addInterceptors(userHandshakeInterceptor)
.setAllowedOrigins("*");
System.out.println("1231");
}
}

46
pom.xml
View File

@@ -25,10 +25,11 @@
<revision>1.0.0</revision>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<maven-surefire-plugin.version>3.0.0-M5</maven-surefire-plugin.version>
<maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version>
<lombok.version>1.18.26</lombok.version>
<spring.boot.version>2.7.11</spring.boot.version>
<maven.surefire.plugin.version>3.0.0-M5</maven.surefire.plugin.version>
<maven.compiler.plugin.version>3.8.1</maven.compiler.plugin.version>
<flatten.maven.plugin.version>1.5.0</flatten.maven.plugin.version>
<lombok.version>1.18.30</lombok.version>
<spring.boot.version>2.7.17</spring.boot.version>
<mapstruct.version>1.5.5.Final</mapstruct.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
@@ -52,13 +53,13 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
<version>${maven.surefire.plugin.version}</version>
</plugin>
<!-- 解决 spring-boot-configuration-processor + Lombok + MapStruct 组合 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<version>${maven.compiler.plugin.version}</version>
<configuration>
<annotationProcessorPaths>
<path>
@@ -79,8 +80,41 @@
</annotationProcessorPaths>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>flatten-maven-plugin</artifactId>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<!-- 统一 revision 版本 -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>flatten-maven-plugin</artifactId>
<version>${flatten.maven.plugin.version}</version>
<configuration>
<flattenMode>resolveCiFriendliesOnly</flattenMode>
<updatePomFile>true</updatePomFile>
</configuration>
<executions>
<execution>
<goals>
<goal>flatten</goal>
</goals>
<id>flatten</id>
<phase>process-resources</phase>
</execution>
<execution>
<goals>
<goal>clean</goal>
</goals>
<id>flatten.clean</id>
<phase>clean</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
<repositories>