未验证 提交 b23fff55 编写于 作者: zlt2000's avatar zlt2000 提交者: Gitee

!26 合并dev

Merge pull request !26 from zlt2000/dev
# zlt-microservices-platform
<p align="center">
<img src="https://img.shields.io/badge/Version-5.3.0-critical" alt="Downloads"/>
<img src="https://img.shields.io/badge/Spring%20Boot-2.5.13-blue" alt="Downloads"/>
<img src="https://img.shields.io/badge/Version-5.4.0-critical" alt="Downloads"/>
<img src="https://img.shields.io/badge/Spring%20Boot-2.5.14-blue" alt="Downloads"/>
<img src="https://img.shields.io/badge/Spring%20Cloud-2020.0.5-blue" alt="Downloads"/>
<img src="https://img.shields.io/badge/Spring%20Cloud%20Alibaba-2021.1-blue" alt="Downloads"/>
<img src="https://img.shields.io/badge/Elasticsearch-7.x-brightgreen" alt="Downloads"/>
......
......@@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.zlt</groupId>
<artifactId>central-platform</artifactId>
<version>5.3.0</version>
<version>5.4.0</version>
<packaging>pom</packaging>
<properties>
......@@ -14,7 +14,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>8</java.version>
<spring-cloud-alibaba-dependencies.version>2021.1</spring-cloud-alibaba-dependencies.version>
<spring-boot-dependencies.version>2.5.13</spring-boot-dependencies.version>
<spring-boot-dependencies.version>2.5.14</spring-boot-dependencies.version>
<spring-cloud-dependencies.version>2020.0.5</spring-cloud-dependencies.version>
<commons-collections4.version>4.4</commons-collections4.version>
<swagger.butler.version>2.0.1</swagger.butler.version>
......
......@@ -4,7 +4,7 @@
<parent>
<groupId>com.zlt</groupId>
<artifactId>zlt-business</artifactId>
<version>5.3.0</version>
<version>5.4.0</version>
</parent>
<artifactId>code-generator</artifactId>
......
......@@ -4,7 +4,7 @@
<parent>
<groupId>com.zlt</groupId>
<artifactId>zlt-business</artifactId>
<version>5.3.0</version>
<version>5.4.0</version>
</parent>
<artifactId>file-center</artifactId>
<description>文件中心</description>
......
......@@ -4,7 +4,7 @@
<parent>
<groupId>com.zlt</groupId>
<artifactId>central-platform</artifactId>
<version>5.3.0</version>
<version>5.4.0</version>
</parent>
<artifactId>zlt-business</artifactId>
<description>业务中心</description>
......
......@@ -4,7 +4,7 @@
<parent>
<groupId>com.zlt</groupId>
<artifactId>zlt-business</artifactId>
<version>5.3.0</version>
<version>5.4.0</version>
</parent>
<artifactId>search-center</artifactId>
<description>搜索中心</description>
......
......@@ -4,7 +4,7 @@
<parent>
<groupId>com.zlt</groupId>
<artifactId>search-center</artifactId>
<version>5.3.0</version>
<version>5.4.0</version>
</parent>
<artifactId>search-client</artifactId>
<description>搜索中心客户端</description>
......
......@@ -4,7 +4,7 @@
<parent>
<groupId>com.zlt</groupId>
<artifactId>search-center</artifactId>
<version>5.3.0</version>
<version>5.4.0</version>
</parent>
<artifactId>search-server</artifactId>
<description>搜索中心服务端</description>
......
......@@ -4,7 +4,7 @@
<parent>
<groupId>com.zlt</groupId>
<artifactId>zlt-business</artifactId>
<version>5.3.0</version>
<version>5.4.0</version>
</parent>
<artifactId>user-center</artifactId>
<description>用户中心</description>
......
......@@ -4,7 +4,7 @@
<parent>
<groupId>com.zlt</groupId>
<artifactId>central-platform</artifactId>
<version>5.3.0</version>
<version>5.4.0</version>
</parent>
<artifactId>zlt-commons</artifactId>
<description>通用组件</description>
......
......@@ -5,7 +5,7 @@
<parent>
<groupId>com.zlt</groupId>
<artifactId>zlt-commons</artifactId>
<version>5.3.0</version>
<version>5.4.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<packaging>jar</packaging>
......
......@@ -2,11 +2,14 @@ package com.central.oauth2.common.util;
import com.central.common.constant.CommonConstant;
import com.central.common.constant.SecurityConstants;
import com.central.common.context.LoginUserContextHolder;
import com.central.common.model.SysUser;
import com.central.common.utils.SpringUtil;
import com.central.oauth2.common.token.CustomWebAuthenticationDetails;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.authentication.AnonymousAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.oauth2.common.OAuth2AccessToken;
import org.springframework.security.oauth2.common.exceptions.InvalidTokenException;
import org.springframework.security.oauth2.common.exceptions.UnapprovedClientAuthenticationException;
......@@ -15,15 +18,16 @@ import org.springframework.security.oauth2.provider.token.TokenStore;
import javax.servlet.http.HttpServletRequest;
import java.nio.charset.StandardCharsets;
import java.util.Base64;
import java.util.Enumeration;
import java.util.Map;
import java.util.*;
/**
* 认证授权相关工具类
*
* @author zlt
* @date 2018/5/13
* <p>
* Blog: https://zlt2000.gitee.io
* Github: https://github.com/zlt2000
*/
@Slf4j
public class AuthUtils {
......@@ -73,12 +77,12 @@ public class AuthUtils {
/**
* 校验accessToken
*/
public static void checkAccessToken(HttpServletRequest request) {
public static SysUser checkAccessToken(HttpServletRequest request) {
String accessToken = extractToken(request);
checkAccessToken(accessToken);
return checkAccessToken(accessToken);
}
public static void checkAccessToken(String accessTokenValue) {
public static SysUser checkAccessToken(String accessTokenValue) {
TokenStore tokenStore = SpringUtil.getBean(TokenStore.class);
OAuth2AccessToken accessToken = tokenStore.readAccessToken(accessTokenValue);
if (accessToken == null || accessToken.getValue() == null) {
......@@ -91,6 +95,17 @@ public class AuthUtils {
if (result == null) {
throw new InvalidTokenException("Invalid access token: " + accessTokenValue);
}
return setContext(result);
}
/**
* 用户信息赋值 context 对象
*/
public static SysUser setContext(Authentication authentication) {
SecurityContextHolder.getContext().setAuthentication(authentication);
SysUser user = getUser(authentication);
LoginUserContextHolder.setUser(user);
return user;
}
/**
......@@ -134,6 +149,21 @@ public class AuthUtils {
return username;
}
/**
* 获取登陆的用户对象
*/
public static SysUser getUser(Authentication authentication) {
SysUser user = null;
if (authentication != null && !(authentication instanceof AnonymousAuthenticationToken)) {
Object principal = authentication.getPrincipal();
//客户端模式只返回一个clientId
if (principal instanceof SysUser) {
user = (SysUser)principal;
}
}
return user;
}
/**
* 获取登陆的帐户类型
*/
......
......@@ -4,7 +4,7 @@
<parent>
<groupId>com.zlt</groupId>
<artifactId>zlt-commons</artifactId>
<version>5.3.0</version>
<version>5.4.0</version>
</parent>
<artifactId>zlt-common-core</artifactId>
<description>公共通用组件</description>
......
......@@ -10,7 +10,7 @@ public interface CommonConstant {
/**
* 项目版本号(banner使用)
*/
String PROJECT_VERSION = "5.3.0";
String PROJECT_VERSION = "5.4.0";
/**
* token请求头名称
......
package com.central.common.context;
import com.alibaba.ttl.TransmittableThreadLocal;
import com.central.common.model.SysUser;
/**
* 登录用户holder
*
* @author zlt
* @date 2022/6/26
* <p>
* Blog: https://zlt2000.gitee.io
* Github: https://github.com/zlt2000
*/
public class LoginUserContextHolder {
private static final ThreadLocal<SysUser> CONTEXT = new TransmittableThreadLocal<>();
public static void setUser(SysUser user) {
CONTEXT.set(user);
}
public static SysUser getUser() {
return CONTEXT.get();
}
public static void clear() {
CONTEXT.remove();
}
}
\ No newline at end of file
......@@ -6,8 +6,12 @@ import com.central.common.constant.SecurityConstants;
import com.central.common.feign.UserService;
import com.central.common.model.SysRole;
import com.central.common.model.SysUser;
import com.central.common.utils.LoginUserUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.MethodParameter;
import org.springframework.security.authentication.AnonymousAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.support.WebDataBinderFactory;
import org.springframework.web.context.request.NativeWebRequest;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
......@@ -61,30 +65,9 @@ public class TokenArgumentResolver implements HandlerMethodArgumentResolver {
LoginUser loginUser = methodParameter.getParameterAnnotation(LoginUser.class);
boolean isFull = loginUser.isFull();
HttpServletRequest request = nativeWebRequest.getNativeRequest(HttpServletRequest.class);
String userId = request.getHeader(SecurityConstants.USER_ID_HEADER);
String username = request.getHeader(SecurityConstants.USER_HEADER);
String roles = request.getHeader(SecurityConstants.ROLE_HEADER);
//账号类型
String accountType = request.getHeader(SecurityConstants.ACCOUNT_TYPE_HEADER);
if (StrUtil.isBlank(username)) {
log.warn("resolveArgument error username is empty");
return null;
}
SysUser user;
if (isFull) {
user = userService.selectByUsername(username);
} else {
user = new SysUser();
user.setId(Long.valueOf(userId));
user.setUsername(username);
}
List<SysRole> sysRoleList = new ArrayList<>();
Arrays.stream(roles.split(",")).forEach(role -> {
SysRole sysRole = new SysRole();
sysRole.setCode(role);
sysRoleList.add(sysRole);
});
user.setRoles(sysRoleList);
return user;
return LoginUserUtils.getCurrentUser(request, isFull);
}
}
package com.central.common.utils;
import cn.hutool.core.util.StrUtil;
import com.central.common.constant.SecurityConstants;
import com.central.common.feign.UserService;
import com.central.common.model.SysRole;
import com.central.common.model.SysUser;
import org.springframework.security.authentication.AnonymousAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
* 获取当前登录人工具类
*
* @author zlt
* @version 1.0
* @date 2022/6/26
* <p>
* Blog: https://zlt2000.gitee.io
* Github: https://github.com/zlt2000
*/
public class LoginUserUtils {
/**
* 获取当前登录人
*/
public static SysUser getCurrentUser(HttpServletRequest request, boolean isFull) {
SysUser user = null;
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
if (authentication != null && !(authentication instanceof AnonymousAuthenticationToken)) {
Object principal = authentication.getPrincipal();
//客户端模式只返回一个clientId
if (principal instanceof SysUser) {
user = (SysUser)principal;
}
}
if (user == null) {
String userId = request.getHeader(SecurityConstants.USER_ID_HEADER);
String username = request.getHeader(SecurityConstants.USER_HEADER);
String roles = request.getHeader(SecurityConstants.ROLE_HEADER);
if (StrUtil.isAllNotBlank(username, userId)) {
if (isFull) {
UserService userService = SpringUtil.getBean(UserService.class);
user = userService.selectByUsername(username);
} else {
user = new SysUser();
user.setId(Long.valueOf(userId));
user.setUsername(username);
}
if (StrUtil.isNotBlank(roles)) {
List<SysRole> sysRoleList = new ArrayList<>();
Arrays.stream(roles.split(",")).forEach(role -> {
SysRole sysRole = new SysRole();
sysRole.setCode(role);
sysRoleList.add(sysRole);
});
user.setRoles(sysRoleList);
}
}
}
return user;
}
}
......@@ -4,7 +4,7 @@
<parent>
<groupId>com.zlt</groupId>
<artifactId>zlt-commons</artifactId>
<version>5.3.0</version>
<version>5.4.0</version>
</parent>
<artifactId>zlt-common-spring-boot-starter</artifactId>
<description>公共通用组件</description>
......
package com.central.common.filter;
import com.central.common.context.LoginUserContextHolder;
import com.central.common.model.SysUser;
import com.central.common.utils.LoginUserUtils;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.core.annotation.Order;
import org.springframework.web.filter.OncePerRequestFilter;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
/**
* 获取当前登录人过滤器
*
* @author zlt
* @date 2022/6/26
* <p>
* Blog: https://zlt2000.gitee.io
* Github: https://github.com/zlt2000
*/
@ConditionalOnClass(Filter.class)
@Order
public class LoginUserFilter extends OncePerRequestFilter {
@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response,
FilterChain filterChain) throws IOException, ServletException {
try {
SysUser user = LoginUserUtils.getCurrentUser(request, false);
LoginUserContextHolder.setUser(user);
filterChain.doFilter(request, response);
} finally {
LoginUserContextHolder.clear();
}
}
}
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
com.central.common.filter.TenantFilter
\ No newline at end of file
com.central.common.filter.TenantFilter, \
com.central.common.filter.LoginUserFilter
\ No newline at end of file
......@@ -5,7 +5,7 @@
<parent>
<groupId>com.zlt</groupId>
<artifactId>zlt-commons</artifactId>
<version>5.3.0</version>
<version>5.4.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<packaging>jar</packaging>
......
......@@ -5,7 +5,7 @@
<parent>
<groupId>com.zlt</groupId>
<artifactId>zlt-commons</artifactId>
<version>5.3.0</version>
<version>5.4.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<packaging>jar</packaging>
......
......@@ -5,7 +5,7 @@
<parent>
<groupId>com.zlt</groupId>
<artifactId>zlt-commons</artifactId>
<version>5.3.0</version>
<version>5.4.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<packaging>jar</packaging>
......
......@@ -5,7 +5,7 @@
<parent>
<groupId>com.zlt</groupId>
<artifactId>zlt-commons</artifactId>
<version>5.3.0</version>
<version>5.4.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<packaging>jar</packaging>
......
......@@ -5,7 +5,7 @@
<parent>
<groupId>com.zlt</groupId>
<artifactId>zlt-commons</artifactId>
<version>5.3.0</version>
<version>5.4.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<packaging>jar</packaging>
......
......@@ -5,7 +5,7 @@
<parent>
<groupId>com.zlt</groupId>
<artifactId>zlt-commons</artifactId>
<version>5.3.0</version>
<version>5.4.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<packaging>jar</packaging>
......
......@@ -5,7 +5,7 @@
<parent>
<groupId>com.zlt</groupId>
<artifactId>zlt-commons</artifactId>
<version>5.3.0</version>
<version>5.4.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<packaging>jar</packaging>
......
......@@ -5,7 +5,7 @@
<parent>
<groupId>com.zlt</groupId>
<artifactId>zlt-commons</artifactId>
<version>5.3.0</version>
<version>5.4.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<packaging>jar</packaging>
......
......@@ -5,7 +5,7 @@
<parent>
<groupId>com.zlt</groupId>
<artifactId>zlt-commons</artifactId>
<version>5.3.0</version>
<version>5.4.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<packaging>jar</packaging>
......
......@@ -5,7 +5,7 @@
<parent>
<groupId>com.zlt</groupId>
<artifactId>central-platform</artifactId>
<version>5.3.0</version>
<version>5.4.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<packaging>jar</packaging>
......
......@@ -7,8 +7,8 @@ spring.cloud.nacos.server-addr=192.168.28.130:8848
#spring.cloud.nacos.username=nacos
#spring.cloud.nacos.password=nacos
spring.cloud.nacos.config.file-extension=yml
spring.cloud.nacos.config.shared-dataids=common.yml
spring.cloud.nacos.config.refreshable-dataids=common.yml
spring.cloud.nacos.config.shared-configs[0].data-id=common.yml
spring.cloud.nacos.config.shared-configs[0].refresh=true
##### spring-boot-actuator配置
management.endpoints.web.exposure.include=*
......
......@@ -6,7 +6,7 @@
<parent>
<groupId>com.zlt</groupId>
<artifactId>zlt-demo</artifactId>
<version>5.3.0</version>
<version>5.4.0</version>
</parent>
<artifactId>dubbo-demo</artifactId>
......
......@@ -4,7 +4,7 @@
<parent>
<groupId>com.zlt</groupId>
<artifactId>central-platform</artifactId>
<version>5.3.0</version>
<version>5.4.0</version>
</parent>
<artifactId>zlt-demo</artifactId>
<packaging>pom</packaging>
......@@ -24,5 +24,7 @@
<module>dubbo-demo</module>
<!-- webSocket集成demo -->
<module>websocket-demo</module>
<!-- 资源服务器demo -->
<module>resources-server-demo</module>
</modules>
</project>
\ No newline at end of file
## 一、说明
资源服务器 demo 样例,以最简化的代码演示如何快速集成一个带鉴权功能的服务,适用于 `无网络隔离` 架构。
> 关于无网络隔离架构的设计可参考文档:[无网络隔离架构](https://www.kancloud.cn/zlt2000/microservices-platform/1153640)
&nbsp;
## 二、启动以下服务
1. zlt-uaa:统一认证中心
2. user-center:用户服务
3. sc-gateway:api网关
4. resources-server-demo
> 环境配置与启动参考文档:https://www.kancloud.cn/zlt2000/microservices-platform/919418
&nbsp;
## 三、测试
### 3.1. 测试接口一
http://localhost:8093/test/notAuth
> 无需token访问
&nbsp;
### 3.2. 测试接口二
通过 @LoginUser 获取当前登录人
http://localhost:8093/test/auth?access_token=xxx
> - xxx 需替换为正确的 access_token
> - 可以通过修改 `bootstrap.yml` 文件中的 `zlt.security.ignore.httpUrls` 参数添加排除校验的url。
&nbsp;
### 3.3. 测试接口三
通过 LoginUserContextHolder 获取当前登录人
http://localhost:8093/test/auth2?access_token=xxx
> - xxx 需替换为正确的 access_token
&nbsp;
## 四、获取access_token
可使用任意授权模式获取;
例如:密码模式授权
- 请求方式:POST
- 请求头:Authorization:Basic d2ViQXBwOndlYkFwcA==
- 请求地址:http://localhost:9900/api-uaa/oauth/token?grant_type=password&username=admin&password=admin
> 授权接口清单参考文档:https://www.kancloud.cn/zlt2000/microservices-platform/1158135
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.zlt</groupId>
<artifactId>zlt-demo</artifactId>
<version>5.4.0</version>
</parent>
<artifactId>resources-server-demo</artifactId>
<dependencies>
<dependency>
<groupId>com.zlt</groupId>
<artifactId>zlt-config</artifactId>
</dependency>
<dependency>
<groupId>com.zlt</groupId>
<artifactId>zlt-common-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>com.zlt</groupId>
<artifactId>zlt-auth-client-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>com.zlt</groupId>
<artifactId>zlt-redis-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-extension</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file
package org.zlt;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
* @author zlt
* @date 2022/6/25
* <p>
* Blog: https://zlt2000.gitee.io
* Github: https://github.com/zlt2000
*/
@SpringBootApplication
public class ResourcesServerApp {
public static void main(String[] args) {
SpringApplication.run(ResourcesServerApp.class, args);
}
}
package org.zlt.config;
import com.central.oauth2.common.config.DefaultResourceServerConf;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer;
/**
* security资源服务器配置
*
* @author zlt
* @version 1.0
* @date 2022/6/25
* <p>
* Blog: https://zlt2000.gitee.io
* Github: https://github.com/zlt2000
*/
@Configuration
@EnableResourceServer
public class MyResourceConfig extends DefaultResourceServerConf {
}
package org.zlt.config;
import com.central.common.config.DefaultWebMvcConfig;
import org.springframework.context.annotation.Configuration;
/**
* web服务器配置
*
* @author zlt
* @version 1.0
* @date 2022/6/25
* <p>
* Blog: https://zlt2000.gitee.io
* Github: https://github.com/zlt2000
*/
@Configuration
public class WebMvcConfig extends DefaultWebMvcConfig {
}
package org.zlt.controller;
import com.central.common.annotation.LoginUser;
import com.central.common.context.LoginUserContextHolder;
import com.central.common.model.SysUser;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @author zlt
* @date 2022/6/25
* <p>
* Blog: https://zlt2000.gitee.io
* Github: https://github.com/zlt2000
*/
@Slf4j
@RestController
public class TestController {
/**
* 通过 @LoginUser 获取当前登录人
*/
@GetMapping("/test/auth")
public String auth(@LoginUser SysUser user) {
return "auth:" + user.getUsername();
}
/**
* 通过 LoginUserContextHolder 获取当前登录人
*/
@GetMapping("/test/auth2")
public String auth() {
return "auth2:" + LoginUserContextHolder.getUser().getUsername();
}
@GetMapping("/test/notAuth")
public String notAuth() {
return "notAuth:ok";
}
}
server:
port: 8093
spring:
application:
name: zlt-resources-server
main:
allow-bean-definition-overriding: true
zlt:
security:
ignore:
httpUrls: >
/test/notAuth
\ No newline at end of file
......@@ -4,7 +4,7 @@
<parent>
<groupId>com.zlt</groupId>
<artifactId>zlt-demo</artifactId>
<version>5.3.0</version>
<version>5.4.0</version>
</parent>
<artifactId>rocketmq-demo</artifactId>
<packaging>pom</packaging>
......
......@@ -4,7 +4,7 @@
<parent>
<groupId>com.zlt</groupId>
<artifactId>rocketmq-demo</artifactId>
<version>5.3.0</version>
<version>5.4.0</version>
</parent>
<artifactId>rocketmq-consume</artifactId>
<description>rocketMQ消费者demo</description>
......
......@@ -4,7 +4,7 @@
<parent>
<groupId>com.zlt</groupId>
<artifactId>rocketmq-demo</artifactId>
<version>5.3.0</version>
<version>5.4.0</version>
</parent>
<artifactId>rocketmq-produce</artifactId>
<description>rocketMQ生产者demo</description>
......
......@@ -4,7 +4,7 @@
<parent>
<groupId>com.zlt</groupId>
<artifactId>rocketmq-demo</artifactId>
<version>5.3.0</version>
<version>5.4.0</version>
</parent>
<artifactId>rocketmq-transactional</artifactId>
<description>rocketMQ事务消息demo</description>
......
......@@ -5,7 +5,7 @@
<parent>
<groupId>com.zlt</groupId>
<artifactId>seata-demo</artifactId>
<version>5.3.0</version>
<version>5.4.0</version>
</parent>
<artifactId>account-service</artifactId>
......
......@@ -5,7 +5,7 @@
<parent>
<groupId>com.zlt</groupId>
<artifactId>seata-demo</artifactId>
<version>5.3.0</version>
<version>5.4.0</version>
</parent>
<artifactId>business-service</artifactId>
......
......@@ -5,7 +5,7 @@
<parent>
<groupId>com.zlt</groupId>
<artifactId>seata-demo</artifactId>
<version>5.3.0</version>
<version>5.4.0</version>
</parent>
<artifactId>order-service</artifactId>
......
......@@ -4,7 +4,7 @@
<parent>
<groupId>com.zlt</groupId>
<artifactId>zlt-demo</artifactId>
<version>5.3.0</version>
<version>5.4.0</version>
</parent>
<artifactId>seata-demo</artifactId>
<description>seata分布式事务demo</description>
......
......@@ -5,7 +5,7 @@
<parent>
<groupId>com.zlt</groupId>
<artifactId>seata-demo</artifactId>
<version>5.3.0</version>
<version>5.4.0</version>
</parent>
<artifactId>seata-common-starter</artifactId>
......
......@@ -5,7 +5,7 @@
<parent>
<groupId>com.zlt</groupId>
<artifactId>seata-demo</artifactId>
<version>5.3.0</version>
<version>5.4.0</version>
</parent>
<artifactId>storage-service</artifactId>
......
......@@ -4,7 +4,7 @@
<parent>
<groupId>com.zlt</groupId>
<artifactId>zlt-demo</artifactId>
<version>5.3.0</version>
<version>5.4.0</version>
</parent>
<artifactId>sharding-jdbc-demo</artifactId>
<description>sharding-jdbc分库分表demo</description>
......
......@@ -4,7 +4,7 @@
<parent>
<groupId>com.zlt</groupId>
<artifactId>sso-demo</artifactId>
<version>5.3.0</version>
<version>5.4.0</version>
</parent>
<artifactId>oidc-sso</artifactId>
<description>OIDC协议单点登录demo</description>
......
......@@ -4,7 +4,7 @@
<parent>
<groupId>com.zlt</groupId>
<artifactId>zlt-demo</artifactId>
<version>5.3.0</version>
<version>5.4.0</version>
</parent>
<artifactId>sso-demo</artifactId>
<packaging>pom</packaging>
......
......@@ -4,7 +4,7 @@
<parent>
<groupId>com.zlt</groupId>
<artifactId>sso-demo</artifactId>
<version>5.3.0</version>
<version>5.4.0</version>
</parent>
<artifactId>ss-sso</artifactId>
<description>springSecurity单点登录demo</description>
......
......@@ -4,7 +4,7 @@
<parent>
<groupId>com.zlt</groupId>
<artifactId>sso-demo</artifactId>
<version>5.3.0</version>
<version>5.4.0</version>
</parent>
<artifactId>web-sso</artifactId>
<description>前后端分离单点登录demo</description>
......
......@@ -4,7 +4,7 @@
<parent>
<groupId>com.zlt</groupId>
<artifactId>zlt-demo</artifactId>
<version>5.3.0</version>
<version>5.4.0</version>
</parent>
<artifactId>txlcn-demo</artifactId>
<description>txlcn分布式事务demo</description>
......
......@@ -4,7 +4,7 @@
<parent>
<groupId>com.zlt</groupId>
<artifactId>txlcn-demo</artifactId>
<version>5.3.0</version>
<version>5.4.0</version>
</parent>
<artifactId>txlcn-demo-common</artifactId>
<name>demo-common</name>
......
......@@ -3,7 +3,7 @@
<parent>
<groupId>com.zlt</groupId>
<artifactId>txlcn-demo</artifactId>
<version>5.3.0</version>
<version>5.4.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
......
......@@ -3,7 +3,7 @@
<parent>
<groupId>com.zlt</groupId>
<artifactId>txlcn-demo</artifactId>
<version>5.3.0</version>
<version>5.4.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>txlcn-demo-spring-service-b</artifactId>
......
......@@ -3,7 +3,7 @@
<parent>
<groupId>com.zlt</groupId>
<artifactId>txlcn-demo</artifactId>
<version>5.3.0</version>
<version>5.4.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>txlcn-demo-spring-service-c</artifactId>
......
......@@ -6,7 +6,7 @@
<parent>
<groupId>com.zlt</groupId>
<artifactId>zlt-demo</artifactId>
<version>5.3.0</version>
<version>5.4.0</version>
</parent>
<artifactId>websocket-demo</artifactId>
......
......@@ -4,7 +4,7 @@
<parent>
<groupId>com.zlt</groupId>
<artifactId>central-platform</artifactId>
<version>5.3.0</version>
<version>5.4.0</version>
</parent>
<artifactId>zlt-gateway</artifactId>
<packaging>pom</packaging>
......
......@@ -4,7 +4,7 @@
<parent>
<groupId>com.zlt</groupId>
<artifactId>zlt-gateway</artifactId>
<version>5.3.0</version>
<version>5.4.0</version>
</parent>
<artifactId>sc-gateway</artifactId>
<description>spring cloud gateway网关</description>
......
......@@ -4,8 +4,8 @@ import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.boot.autoconfigure.web.ResourceProperties;
import org.springframework.boot.autoconfigure.web.ServerProperties;
import org.springframework.boot.autoconfigure.web.WebProperties;
import org.springframework.boot.autoconfigure.web.reactive.WebFluxAutoConfiguration;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.web.reactive.error.ErrorAttributes;
......@@ -35,26 +35,26 @@ import java.util.List;
@ConditionalOnWebApplication(type = ConditionalOnWebApplication.Type.REACTIVE)
@ConditionalOnClass(WebFluxConfigurer.class)
@AutoConfigureBefore(WebFluxAutoConfiguration.class)
@EnableConfigurationProperties({ServerProperties.class, ResourceProperties.class})
@EnableConfigurationProperties({ServerProperties.class, WebProperties.class})
public class CustomErrorWebFluxAutoConfiguration {
private final ServerProperties serverProperties;
private final ApplicationContext applicationContext;
private final ResourceProperties resourceProperties;
private final WebProperties webProperties;
private final List<ViewResolver> viewResolvers;
private final ServerCodecConfigurer serverCodecConfigurer;
public CustomErrorWebFluxAutoConfiguration(ServerProperties serverProperties,
ResourceProperties resourceProperties,
WebProperties webProperties,
ObjectProvider<List<ViewResolver>> viewResolversProvider,
ServerCodecConfigurer serverCodecConfigurer,
ApplicationContext applicationContext) {
this.serverProperties = serverProperties;
this.applicationContext = applicationContext;
this.resourceProperties = resourceProperties;
this.webProperties = webProperties;
this.viewResolvers = viewResolversProvider.getIfAvailable(Collections::emptyList);
this.serverCodecConfigurer = serverCodecConfigurer;
}
......@@ -64,7 +64,7 @@ public class CustomErrorWebFluxAutoConfiguration {
public ErrorWebExceptionHandler errorWebExceptionHandler(ErrorAttributes errorAttributes) {
JsonErrorWebExceptionHandler exceptionHandler = new JsonErrorWebExceptionHandler(
errorAttributes,
this.resourceProperties,
this.webProperties.getResources(),
this.serverProperties.getError(),
this.applicationContext);
exceptionHandler.setViewResolvers(this.viewResolvers);
......
package com.central.gateway.error;
import org.springframework.boot.autoconfigure.web.ErrorProperties;
import org.springframework.boot.autoconfigure.web.ResourceProperties;
import org.springframework.boot.autoconfigure.web.WebProperties;
import org.springframework.boot.autoconfigure.web.reactive.error.DefaultErrorWebExceptionHandler;
import org.springframework.boot.web.error.ErrorAttributeOptions;
import org.springframework.boot.web.reactive.error.ErrorAttributes;
......@@ -23,7 +23,7 @@ import java.util.Map;
* Github: https://github.com/zlt2000
*/
public class JsonErrorWebExceptionHandler extends DefaultErrorWebExceptionHandler {
public JsonErrorWebExceptionHandler(ErrorAttributes errorAttributes, ResourceProperties resourceProperties,
public JsonErrorWebExceptionHandler(ErrorAttributes errorAttributes, WebProperties.Resources resourceProperties,
ErrorProperties errorProperties, ApplicationContext applicationContext) {
super(errorAttributes, resourceProperties, errorProperties, applicationContext);
}
......
......@@ -4,7 +4,7 @@
<parent>
<groupId>com.zlt</groupId>
<artifactId>zlt-job</artifactId>
<version>5.3.0</version>
<version>5.4.0</version>
</parent>
<artifactId>job-admin</artifactId>
<packaging>jar</packaging>
......
......@@ -4,7 +4,7 @@
<parent>
<groupId>com.zlt</groupId>
<artifactId>zlt-job</artifactId>
<version>5.3.0</version>
<version>5.4.0</version>
</parent>
<artifactId>job-core</artifactId>
<packaging>jar</packaging>
......
......@@ -6,7 +6,7 @@
<parent>
<groupId>com.zlt</groupId>
<artifactId>zlt-job</artifactId>
<version>5.3.0</version>
<version>5.4.0</version>
</parent>
<artifactId>job-executor-samples</artifactId>
<packaging>jar</packaging>
......
......@@ -4,7 +4,7 @@
<parent>
<groupId>com.zlt</groupId>
<artifactId>central-platform</artifactId>
<version>5.3.0</version>
<version>5.4.0</version>
</parent>
<artifactId>zlt-job</artifactId>
<packaging>pom</packaging>
......
......@@ -4,7 +4,7 @@
<parent>
<groupId>com.zlt</groupId>
<artifactId>zlt-monitor</artifactId>
<version>5.3.0</version>
<version>5.4.0</version>
</parent>
<artifactId>log-center</artifactId>
<dependencies>
......
......@@ -3,7 +3,7 @@
<parent>
<groupId>com.zlt</groupId>
<artifactId>central-platform</artifactId>
<version>5.3.0</version>
<version>5.4.0</version>
</parent>
<artifactId>zlt-monitor</artifactId>
<packaging>pom</packaging>
......
......@@ -4,7 +4,7 @@
<parent>
<groupId>com.zlt</groupId>
<artifactId>zlt-monitor</artifactId>
<version>5.3.0</version>
<version>5.4.0</version>
</parent>
<artifactId>sc-admin</artifactId>
......
......@@ -4,7 +4,7 @@
<parent>
<groupId>com.zlt</groupId>
<artifactId>central-platform</artifactId>
<version>5.3.0</version>
<version>5.4.0</version>
</parent>
<artifactId>zlt-transaction</artifactId>
<description>事务</description>
......
......@@ -3,7 +3,7 @@
<parent>
<groupId>com.zlt</groupId>
<artifactId>zlt-transaction</artifactId>
<version>5.3.0</version>
<version>5.4.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>txlcn-tm</artifactId>
......
......@@ -4,7 +4,7 @@
<parent>
<groupId>com.zlt</groupId>
<artifactId>central-platform</artifactId>
<version>5.3.0</version>
<version>5.4.0</version>
</parent>
<artifactId>zlt-uaa</artifactId>
<description>认证中心</description>
......
......@@ -6,7 +6,7 @@
<parent>
<groupId>com.zlt</groupId>
<artifactId>zlt-web</artifactId>
<version>5.3.0</version>
<version>5.4.0</version>
</parent>
<artifactId>back-web</artifactId>
<description>后台管理前端</description>
......
......@@ -6,7 +6,7 @@
<parent>
<groupId>com.zlt</groupId>
<artifactId>central-platform</artifactId>
<version>5.3.0</version>
<version>5.4.0</version>
</parent>
<artifactId>zlt-web</artifactId>
<description>前端</description>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册