Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
architecture
/
glsx-archetype
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit d4b0d309
authored
Apr 06, 2023
by
刘宇峰
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
整理框架
1 parent
79f917df
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
101 additions
and
67 deletions
rest-archetype-framework/pom.xml
rest-archetype-framework/rest-admin-context/src/main/java/com/glsx/plat/context/config/ThreadPoolConfig.java
rest-archetype-framework/rest-admin-dubbo/pom.xml
rest-archetype-framework/rest-admin-elasticjob/pom.xml
rest-archetype-framework/rest-admin-feign/src/main/java/com/glsx/plat/feign/config/FeignInterceptor.java
rest-archetype-framework/rest-admin-swagger3/pom.xml
rest-archetype-framework/rest-admin-swagger3/src/main/java/com/glsx/plat/swagger3/config/Swagger3Config.java
rest-archetype-framework/pom.xml
View file @
d4b0d30
...
@@ -71,6 +71,14 @@
...
@@ -71,6 +71,14 @@
<type>
pom
</type>
<type>
pom
</type>
<scope>
import
</scope>
<scope>
import
</scope>
</dependency>
</dependency>
<dependency>
<groupId>
org.apache.dubbo
</groupId>
<artifactId>
dubbo-bom
</artifactId>
<version>
3.0.2.1
</version>
<type>
pom
</type>
<scope>
import
</scope>
</dependency>
</dependencies>
</dependencies>
</dependencyManagement>
</dependencyManagement>
...
...
rest-archetype-framework/rest-admin-context/src/main/java/com/glsx/plat/context/config/ThreadPoolConfig.java
View file @
d4b0d30
...
@@ -5,7 +5,6 @@ import org.apache.commons.lang.time.DateUtils;
...
@@ -5,7 +5,6 @@ import org.apache.commons.lang.time.DateUtils;
import
org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler
;
import
org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler
;
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.scheduling.annotation.AsyncConfigurer
;
import
org.springframework.scheduling.annotation.EnableAsync
;
import
org.springframework.scheduling.annotation.EnableAsync
;
import
org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor
;
import
org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor
;
...
@@ -18,7 +17,7 @@ import java.util.concurrent.ThreadPoolExecutor;
...
@@ -18,7 +17,7 @@ import java.util.concurrent.ThreadPoolExecutor;
@Slf4j
@Slf4j
@EnableAsync
@EnableAsync
@Configuration
@Configuration
public
class
ThreadPoolConfig
implements
AsyncConfigurer
{
public
class
ThreadPoolConfig
{
DefaultRejectedExecutionHandler
rejectedExecutionHandler
=
new
DefaultRejectedExecutionHandler
();
DefaultRejectedExecutionHandler
rejectedExecutionHandler
=
new
DefaultRejectedExecutionHandler
();
// 线程池维护线程的最少数量
// 线程池维护线程的最少数量
...
@@ -26,10 +25,9 @@ public class ThreadPoolConfig implements AsyncConfigurer {
...
@@ -26,10 +25,9 @@ public class ThreadPoolConfig implements AsyncConfigurer {
//最大线程池大小
//最大线程池大小
private
int
maxPoolSize
=
150
;
private
int
maxPoolSize
=
150
;
//队列容量,排队数
//队列容量,排队数
private
int
queueCapacity
=
1000
0
;
private
int
queueCapacity
=
1000
;
@Bean
(
name
=
"threadPoolTaskExecutor"
)
@Bean
(
name
=
"threadPoolTaskExecutor"
)
@Override
public
ThreadPoolTaskExecutor
getAsyncExecutor
()
{
public
ThreadPoolTaskExecutor
getAsyncExecutor
()
{
ThreadPoolTaskExecutor
threadPoolTaskExecutor
=
new
ThreadPoolTaskExecutor
();
ThreadPoolTaskExecutor
threadPoolTaskExecutor
=
new
ThreadPoolTaskExecutor
();
//设置核心线程数
//设置核心线程数
...
@@ -41,7 +39,7 @@ public class ThreadPoolConfig implements AsyncConfigurer {
...
@@ -41,7 +39,7 @@ public class ThreadPoolConfig implements AsyncConfigurer {
//设置线程活跃时间(秒) 最大允许空闲时间,超过时间并且当前池中线程数大于 corePoolSize 的时候会销毁
//设置线程活跃时间(秒) 最大允许空闲时间,超过时间并且当前池中线程数大于 corePoolSize 的时候会销毁
threadPoolTaskExecutor
.
setKeepAliveSeconds
(
60
);
threadPoolTaskExecutor
.
setKeepAliveSeconds
(
60
);
//设置默认线程名称
//设置默认线程名称
threadPoolTaskExecutor
.
setThreadNamePrefix
(
"p
ayu
-"
);
threadPoolTaskExecutor
.
setThreadNamePrefix
(
"p
lat
-"
);
//设置拒绝策略
//设置拒绝策略
// threadPoolTaskExecutor.setRejectedExecutionHandler(rejectedExecutionHandler);
// threadPoolTaskExecutor.setRejectedExecutionHandler(rejectedExecutionHandler);
threadPoolTaskExecutor
.
setRejectedExecutionHandler
(
new
ThreadPoolExecutor
.
CallerRunsPolicy
());
threadPoolTaskExecutor
.
setRejectedExecutionHandler
(
new
ThreadPoolExecutor
.
CallerRunsPolicy
());
...
@@ -56,7 +54,6 @@ public class ThreadPoolConfig implements AsyncConfigurer {
...
@@ -56,7 +54,6 @@ public class ThreadPoolConfig implements AsyncConfigurer {
*
*
* @return
* @return
*/
*/
@Override
public
AsyncUncaughtExceptionHandler
getAsyncUncaughtExceptionHandler
()
{
public
AsyncUncaughtExceptionHandler
getAsyncUncaughtExceptionHandler
()
{
AsyncUncaughtExceptionHandler
asyncUncaughtExceptionHandler
=
(
throwable
,
method
,
objects
)
->
{
AsyncUncaughtExceptionHandler
asyncUncaughtExceptionHandler
=
(
throwable
,
method
,
objects
)
->
{
log
.
error
(
method
.
getName
()
+
" 执行异常"
,
throwable
);
log
.
error
(
method
.
getName
()
+
" 执行异常"
,
throwable
);
...
...
rest-archetype-framework/rest-admin-dubbo/pom.xml
View file @
d4b0d30
...
@@ -12,14 +12,14 @@
...
@@ -12,14 +12,14 @@
<artifactId>
rest-admin-dubbo
</artifactId>
<artifactId>
rest-admin-dubbo
</artifactId>
<properties>
<properties>
<curator.version>
4.2.0
</curator.version>
<curator.version>
5.2.1
</curator.version>
<zookeeper.version>
3.6.0
</zookeeper.version>
</properties>
</properties>
<dependencies>
<dependencies>
<dependency>
<dependency>
<groupId>
org.apache.curator
</groupId>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
curator-framework
</artifactId>
<artifactId>
spring-cloud-starter-zookeeper-discovery
</artifactId>
<version>
${curator.version}
</version>
<exclusions>
<exclusions>
<exclusion>
<exclusion>
<groupId>
org.apache.zookeeper
</groupId>
<groupId>
org.apache.zookeeper
</groupId>
...
@@ -28,32 +28,23 @@
...
@@ -28,32 +28,23 @@
</exclusions>
</exclusions>
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>
org.apache.
curato
r
</groupId>
<groupId>
org.apache.
zookeepe
r
</groupId>
<artifactId>
curator-recipes
</artifactId>
<artifactId>
zookeeper
</artifactId>
<version>
${
curato
r.version}
</version>
<version>
${
zookeepe
r.version}
</version>
</dependency>
</dependency>
<dependency>
<!-- <dependency>-->
<groupId>
com.101tec
</groupId>
<!-- <groupId>org.apache.dubbo</groupId>-->
<artifactId>
zkclient
</artifactId>
<!-- <artifactId>dubbo-registry-nacos</artifactId>-->
<version>
0.11
</version>
<!-- </dependency>-->
<!--排除这个slf4j-log4j12-->
<!-- <dependency>-->
<exclusions>
<!-- <groupId>com.alibaba.nacos</groupId>-->
<exclusion>
<!-- <artifactId>nacos-client</artifactId>-->
<groupId>
org.slf4j
</groupId>
<!-- </dependency>-->
<artifactId>
slf4j-log4j12
</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<groupId>
org.apache.dubbo
</groupId>
<artifactId>
spring-boot-starter-actuator
</artifactId>
<artifactId>
dubbo-spring-boot-starter
</artifactId>
</dependency>
<dependency>
<groupId>
com.alibaba.cloud
</groupId>
<artifactId>
spring-cloud-starter-dubbo
</artifactId>
<version>
2.2.6.RELEASE
</version>
</dependency>
</dependency>
</dependencies>
</dependencies>
</project>
</project>
\ No newline at end of file
\ No newline at end of file
rest-archetype-framework/rest-admin-elasticjob/pom.xml
View file @
d4b0d30
...
@@ -11,44 +11,27 @@
...
@@ -11,44 +11,27 @@
<artifactId>
rest-admin-elasticjob
</artifactId>
<artifactId>
rest-admin-elasticjob
</artifactId>
<properties>
<curator.version>
5.2.0
</curator.version>
<zookeeper.version>
3.7.0
</zookeeper.version>
</properties>
<dependencies>
<dependencies>
<dependency>
<dependency>
<groupId>
com.github.kuhn-he
</groupId>
<groupId>
org.apache.shardingsphere.elasticjob
</groupId>
<artifactId>
elastic
-
job-lite-spring-boot-starter
</artifactId>
<artifactId>
elasticjob-lite-spring-boot-starter
</artifactId>
<version>
2.1.53
</version>
<version>
3.0.0
</version>
<exclusions>
<exclusions>
<exclusion>
<exclusion>
<groupId>
org.apache.curator
</groupId>
<groupId>
org.apache.zookeeper
</groupId>
<artifactId>
curator-recipes
</artifactId>
<artifactId>
zookeeper
</artifactId>
</exclusion>
<exclusion>
<groupId>
org.apache.curator
</groupId>
<artifactId>
curator-framework
</artifactId>
</exclusion>
<exclusion>
<groupId>
com.google.guava
</groupId>
<artifactId>
guava
</artifactId>
</exclusion>
</exclusion>
</exclusions>
</exclusions>
</dependency>
</dependency>
<!-- zookeeper 分布式锁、注意zookeeper版本 版本限制-->
<dependency>
<groupId>
org.apache.curator
</groupId>
<artifactId>
curator-recipes
</artifactId>
<version>
2.10.0
</version>
</dependency>
<dependency>
<groupId>
org.apache.curator
</groupId>
<artifactId>
curator-framework
</artifactId>
<version>
2.10.0
</version>
</dependency>
<dependency>
<dependency>
<groupId>
com.google.guava
</groupId>
<groupId>
org.apache.zookeeper
</groupId>
<artifactId>
guava
</artifactId>
<artifactId>
zookeeper
</artifactId>
<version>
18.0
</version>
<version>
${zookeeper.version}
</version>
</dependency>
</dependency>
<dependency>
<dependency>
...
...
rest-archetype-framework/rest-admin-feign/src/main/java/com/glsx/plat/feign/config/FeignInterceptor.java
View file @
d4b0d30
...
@@ -40,7 +40,7 @@ public class FeignInterceptor implements RequestInterceptor {
...
@@ -40,7 +40,7 @@ public class FeignInterceptor implements RequestInterceptor {
}
}
}
}
}
}
log
.
info
(
"feign interceptor template requestURL:{},querystring:{}"
,
request
.
getRequestURL
(),
request
.
getQueryString
());
log
.
debug
(
"feign interceptor template requestURL:{},querystring:{}"
,
request
.
getRequestURL
(),
request
.
getQueryString
());
}
}
}
}
rest-archetype-framework/rest-admin-swagger3/pom.xml
View file @
d4b0d30
...
@@ -12,15 +12,26 @@
...
@@ -12,15 +12,26 @@
<artifactId>
rest-admin-swagger3
</artifactId>
<artifactId>
rest-admin-swagger3
</artifactId>
<properties>
<properties>
<swagger2.version>
3.0.0
</swagger2.version>
<swagger3.version>
3.0.0
</swagger3.version>
<knife4j.version>
3.0.2
</knife4j.version>
</properties>
</properties>
<dependencies>
<dependencies>
<!--swagger 文档-->
<!--swagger 文档-->
<!-- <dependency>-->
<!-- <groupId>io.springfox</groupId>-->
<!-- <artifactId>springfox-boot-starter</artifactId>-->
<!-- <version>${swagger3.version}</version>-->
<!-- </dependency>-->
<dependency>
<dependency>
<groupId>
io.springfox
</groupId>
<groupId>
com.github.xiaoymin
</groupId>
<artifactId>
springfox-boot-starter
</artifactId>
<artifactId>
knife4j-spring-boot-starter
</artifactId>
<version>
3.0.0
</version>
<!--在引用时请在maven中央仓库搜索3.X最新版本号-->
<version>
3.0.2
</version>
</dependency>
<dependency>
<groupId>
org.springframework
</groupId>
<artifactId>
spring-webmvc
</artifactId>
</dependency>
</dependency>
</dependencies>
</dependencies>
</project>
</project>
\ No newline at end of file
\ No newline at end of file
rest-archetype-framework/rest-admin-swagger3/src/main/java/com/glsx/plat/swagger3/config/Swagger3Config.java
View file @
d4b0d30
package
com
.
glsx
.
plat
.
swagger3
.
config
;
package
com
.
glsx
.
plat
.
swagger3
.
config
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.beans.BeansException
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.config.BeanPostProcessor
;
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.util.ReflectionUtils
;
import
org.springframework.web.servlet.mvc.method.RequestMappingInfoHandlerMapping
;
import
springfox.documentation.builders.ApiInfoBuilder
;
import
springfox.documentation.builders.ApiInfoBuilder
;
import
springfox.documentation.builders.ParameterBuilder
;
import
springfox.documentation.builders.ParameterBuilder
;
import
springfox.documentation.builders.PathSelectors
;
import
springfox.documentation.builders.PathSelectors
;
...
@@ -14,10 +18,14 @@ import springfox.documentation.service.*;
...
@@ -14,10 +18,14 @@ import springfox.documentation.service.*;
import
springfox.documentation.spi.DocumentationType
;
import
springfox.documentation.spi.DocumentationType
;
import
springfox.documentation.spi.service.contexts.SecurityContext
;
import
springfox.documentation.spi.service.contexts.SecurityContext
;
import
springfox.documentation.spring.web.plugins.Docket
;
import
springfox.documentation.spring.web.plugins.Docket
;
import
springfox.documentation.spring.web.plugins.WebFluxRequestHandlerProvider
;
import
springfox.documentation.spring.web.plugins.WebMvcRequestHandlerProvider
;
import
java.lang.reflect.Field
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.List
;
import
java.util.stream.Collectors
;
@Configuration
@Configuration
@EnableOpenApi
@EnableOpenApi
...
@@ -83,4 +91,40 @@ public class Swagger3Config {
...
@@ -83,4 +91,40 @@ public class Swagger3Config {
};
};
}
}
/**
* 增加如下配置可解决Spring Boot 6.x 与Swagger 3.0.0 不兼容问题
**/
@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
<
T
extends
RequestMappingInfoHandlerMapping
>
void
customizeSpringfoxHandlerMappings
(
List
<
T
>
mappings
)
{
List
<
T
>
copy
=
mappings
.
stream
()
.
filter
(
mapping
->
mapping
.
getPatternParser
()
==
null
)
.
collect
(
Collectors
.
toList
());
mappings
.
clear
();
mappings
.
addAll
(
copy
);
}
@SuppressWarnings
(
"unchecked"
)
private
List
<
RequestMappingInfoHandlerMapping
>
getHandlerMappings
(
Object
bean
)
{
try
{
Field
field
=
ReflectionUtils
.
findField
(
bean
.
getClass
(),
"handlerMappings"
);
field
.
setAccessible
(
true
);
return
(
List
<
RequestMappingInfoHandlerMapping
>)
field
.
get
(
bean
);
}
catch
(
IllegalArgumentException
|
IllegalAccessException
e
)
{
throw
new
IllegalStateException
(
e
);
}
}
};
}
}
}
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment