尝试用统一初始化数据表,实现表的统一规范处理, 但mybatis plus不支持, 尝试了一个组件支持的能力比较差,远不如 jpa修改校验规则
This commit is contained in:
parent
ea589042c2
commit
62b3b1f435
|
@ -15,30 +15,12 @@
|
|||
|
||||
<dependencies>
|
||||
<!-- spring web 依赖 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-validation</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.xiaoymin</groupId>
|
||||
<artifactId>knife4j-openapi2-spring-boot-starter</artifactId>
|
||||
<version>${knife4j.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger-ui</artifactId>
|
||||
<version>${swagger.ui.version}</version>
|
||||
</dependency>
|
||||
<!-- jdbc 依赖 -->
|
||||
<dependency>
|
||||
<groupId>com.mchange</groupId>
|
||||
<artifactId>c3p0</artifactId>
|
||||
<version>${c3p0.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||
|
|
|
@ -12,18 +12,17 @@ import java.util.Date;
|
|||
@Data
|
||||
public class Base {
|
||||
@TableId
|
||||
@ApiModelProperty(value = "用户主键")
|
||||
@ApiModelProperty(value = "主键")
|
||||
private Integer id;
|
||||
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
|
||||
@TableField("create_at")
|
||||
@TableField("create_time")
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
private Date createAt;
|
||||
private Date createTime;
|
||||
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
|
||||
@TableField("update_at")
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
private Date updateAt;
|
||||
@TableField("update_time")
|
||||
@ApiModelProperty(value = "修改时间")
|
||||
private Date updateTime;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
package com.common.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@TableName(value = "dic_target")
|
||||
public class DicTarget extends Base{
|
||||
@TableField("type")
|
||||
@ApiModelProperty(value = "指标类型")
|
||||
private String type;
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
package com.common.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@TableName(value = "p_role")
|
||||
public class Role extends Base{
|
||||
@TableField("role_type")
|
||||
@ApiModelProperty(value = "角色类型")
|
||||
private String roleType;
|
||||
@TableField("role_name")
|
||||
@ApiModelProperty(value = "角色名称")
|
||||
private String roleName;
|
||||
@TableField("role_desc")
|
||||
@ApiModelProperty(value = "角色描述")
|
||||
private String roleDesc;
|
||||
@TableField("create_by")
|
||||
@ApiModelProperty(value = "角色创建人")
|
||||
private String createBy;
|
||||
@TableField("data_scope")
|
||||
@ApiModelProperty(value="数据权限定义1-全部权限 2-本部门及以下部门 3-本部门 4-本人 5-自定义 ")
|
||||
private Integer dataScope;
|
||||
@ApiModelProperty(value="数据权限定义部门id集合 ")
|
||||
private List<Integer> dataDeptIds;
|
||||
}
|
|
@ -1,62 +0,0 @@
|
|||
package com.common.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@TableName(value = "p_scene")
|
||||
public class Scene extends Base{
|
||||
@TableField("scene_name")
|
||||
@ApiModelProperty(value = "技能名称")
|
||||
private String sceneName;
|
||||
@TableField("scene_remark")
|
||||
@ApiModelProperty(value = "备注")
|
||||
private String sceneRemark;
|
||||
@ApiModelProperty(value = "角色串")
|
||||
private String roles;
|
||||
@TableField("model_notes")
|
||||
@ApiModelProperty(value = "模型说明")
|
||||
private String modelNotes;
|
||||
@TableField("file_url")
|
||||
@ApiModelProperty(value = "文件地址")
|
||||
private String fileUrl;
|
||||
@ApiModelProperty(value = "版本")
|
||||
private String version;
|
||||
@TableField("contribution_name")
|
||||
@ApiModelProperty(value = "贡献者姓名")
|
||||
private String contributionName;
|
||||
@TableField("scene_type")
|
||||
@ApiModelProperty(value = "技能类别 1定制 2永洪 ")
|
||||
private Short sceneType;
|
||||
@TableField("scene_url")
|
||||
@ApiModelProperty(value = "技能URL")
|
||||
private String sceneUrl;
|
||||
@TableField("scene_skin")
|
||||
@ApiModelProperty(value = "场景皮肤")
|
||||
private String sceneSkin;
|
||||
@TableField("icon_url")
|
||||
@ApiModelProperty(value = "icon地址")
|
||||
private String iconUrl;
|
||||
@TableField("create_by")
|
||||
@ApiModelProperty(value = "创建人")
|
||||
private String createBy;
|
||||
@TableField("update_by")
|
||||
@ApiModelProperty(value = "更新人")
|
||||
private String updateBy;
|
||||
@ApiModelProperty(value = "删除标记:0-未删除 1-已删除")
|
||||
private Short deleted;
|
||||
@TableField("scene_operation")
|
||||
@ApiModelProperty(value = "技能类型 智能脑,聪明口,灵活手,千里眼")
|
||||
private String sceneOperation;
|
||||
@TableField("scene_order")
|
||||
@ApiModelProperty(value = "排序")
|
||||
private Integer sceneOrder;
|
||||
@TableField("scene_code")
|
||||
@ApiModelProperty(value = "场景编码")
|
||||
private String sceneCode;
|
||||
@TableField("scene_tag")
|
||||
@ApiModelProperty(value = "场景标签")
|
||||
private String sceneTag;
|
||||
}
|
|
@ -49,7 +49,7 @@ public class User {
|
|||
private String roleLevel;
|
||||
@ApiModelProperty(value = "用户角色,role id以逗号拼接")
|
||||
private Set<String> roles;
|
||||
//与实体不一致
|
||||
//与其它实体类型和命名不一致
|
||||
@TableField("create_time")
|
||||
@ApiModelProperty(value="角色列表")
|
||||
private OffsetDateTime createTime;
|
||||
|
|
|
@ -34,7 +34,7 @@ comment on column public.p_user.create_time is '创建时间';
|
|||
comment on column public.p_user.update_time is '更新时间';
|
||||
comment on column public.p_user.job_title is '职称';
|
||||
comment on column public.p_user.role_level is '等级:0运营 1派出所 2分局';
|
||||
comment on column public.p_user.roles is 'roleid以逗号拼接';
|
||||
comment on column public.p_user.roles is 'role id以逗号拼接';
|
||||
|
||||
drop table if exists public.p_role;
|
||||
create table public.p_role (
|
||||
|
@ -57,7 +57,7 @@ comment on column public.p_role.create_by is '创建人';
|
|||
comment on column public.p_role.update_at is '修改时间';
|
||||
comment on column public.p_role.update_by is '修改人';
|
||||
comment on column public.p_role.deleted is '删除标记 0-未删除 1-已删除';
|
||||
comment on column public.p_role.data_scope is '数据权限定义1-全部权限 2-本部门及以下部门 3-本部门 4-本人 5-自定义';
|
||||
comment on column public.p_role.data_scope is '数据权限定义 1-全部权限 2-本部门及以下部门 3-本部门 4-本人 5-自定义';
|
||||
|
||||
drop table if exists public.p_scene;
|
||||
create table public.p_scene (
|
||||
|
|
3
pom.xml
3
pom.xml
|
@ -36,11 +36,8 @@
|
|||
<spring.cloud.version>2021.0.8</spring.cloud.version>
|
||||
<spring-cloud-alibaba.version>2021.1</spring-cloud-alibaba.version>
|
||||
<spring.plugin.version>2.7.17</spring.plugin.version>
|
||||
<!-- 权限包 -->
|
||||
<jwt.version>4.2.2</jwt.version>
|
||||
<!-- jdbc -->
|
||||
<mybatis.plus.version>3.5.5</mybatis.plus.version>
|
||||
<mybatis.plugin.version>1.4.2</mybatis.plugin.version>
|
||||
<c3p0.version>0.9.5.5</c3p0.version>
|
||||
<mysql.version>8.0.28</mysql.version>
|
||||
<postgresql.version>42.3.8</postgresql.version>
|
||||
|
|
27
zbsz/pom.xml
27
zbsz/pom.xml
|
@ -19,7 +19,27 @@
|
|||
<groupId>com.szr</groupId>
|
||||
<artifactId>common</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- spring web 依赖 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-validation</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger-ui</artifactId>
|
||||
<version>${swagger.ui.version}</version>
|
||||
</dependency>
|
||||
<!-- jdbc 依赖 -->
|
||||
<dependency>
|
||||
<groupId>com.mchange</groupId>
|
||||
<artifactId>c3p0</artifactId>
|
||||
<version>${c3p0.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.postgresql</groupId>
|
||||
<artifactId>postgresql</artifactId>
|
||||
|
@ -35,13 +55,6 @@
|
|||
<artifactId>spring-boot-starter-aop</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- security -->
|
||||
<dependency>
|
||||
<groupId>com.auth0</groupId>
|
||||
<artifactId>java-jwt</artifactId>
|
||||
<version>${jwt.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 热部署 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.zbsz;
|
||||
|
||||
import com.zbsz.init.CustomInitializer;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
@ -7,7 +8,10 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|||
@SpringBootApplication
|
||||
@MapperScan("com.zbsz.mapper")
|
||||
public class Run {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(Run.class,args);
|
||||
SpringApplication application = new SpringApplication(Run.class);
|
||||
application.addInitializers(new CustomInitializer());
|
||||
application.run();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ public class LogAop {
|
|||
Object result=joinPoint.proceed();
|
||||
log.info("Response:"+ JSON.toJSON(result));
|
||||
log.info("耗时:"+(System.currentTimeMillis()-startTime));
|
||||
log.info("==================End=================");
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -31,17 +32,13 @@ public class LogAop {
|
|||
public void doBefore(JoinPoint joinPoint) {
|
||||
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
||||
HttpServletRequest request = attributes.getRequest();
|
||||
log.info("");
|
||||
log.info("==================Start=================");
|
||||
log.info("URL:" + request.getRequestURL().toString());
|
||||
log.info("Method:" + request.getMethod().toString());
|
||||
log.info("Class Method:" + joinPoint.getSignature().getDeclaringTypeName() + "," + joinPoint.getSignature().getName());
|
||||
log.info("客户端IP:" + request.getRemoteAddr());
|
||||
log.info("请求参数:" + JSON.toJSON(joinPoint.getArgs()));
|
||||
|
||||
}
|
||||
|
||||
@After("log()")
|
||||
public void doAfter() {
|
||||
log.info("==================End=================");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@ import com.common.entity.User;
|
|||
import com.zbsz.info.LoginInfo;
|
||||
import com.zbsz.info.Result;
|
||||
import com.zbsz.service.UserService;
|
||||
import com.zbsz.tool.JwtTool;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
@ -38,7 +37,7 @@ public class OpenApiController {
|
|||
if(user!=null){
|
||||
result.setCode(CodeMsg.SUCCESS.getCode());
|
||||
result.setMsg(CodeMsg.SUCCESS.getMessage());
|
||||
result.setData(JwtTool.getToken(info.getUserName()));
|
||||
result.setData("真 * token 串");
|
||||
log.error("-------- 登录成功 ");
|
||||
}else {
|
||||
result.setCode(CodeMsg.AUTH_FAILURE.getCode());
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
package com.zbsz.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.common.entity.Base;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@TableName(value = "zb_t_target")
|
||||
public class Target extends Base {
|
||||
@TableField("target_id")
|
||||
@ApiModelProperty(value = "指标编号")
|
||||
private String targetId;
|
||||
@TableField("target_name")
|
||||
@ApiModelProperty(value = "指标名称")
|
||||
private String targetName;
|
||||
}
|
|
@ -1,13 +1,15 @@
|
|||
package com.zbsz.filter;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.common.entity.User;
|
||||
import com.common.info.CodeMsg;
|
||||
import com.zbsz.info.Result;
|
||||
import com.zbsz.tool.JwtTool;
|
||||
import com.zbsz.service.UserService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.method.HandlerMethod;
|
||||
import org.springframework.web.servlet.HandlerInterceptor;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.PrintWriter;
|
||||
|
@ -15,6 +17,9 @@ import java.io.PrintWriter;
|
|||
@Slf4j
|
||||
public class JwtInterceptor implements HandlerInterceptor {
|
||||
|
||||
@Resource
|
||||
private UserService userService;
|
||||
|
||||
//判断然后进行用户拦截
|
||||
@Override
|
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) {
|
||||
|
@ -23,23 +28,22 @@ public class JwtInterceptor implements HandlerInterceptor {
|
|||
return true;
|
||||
}
|
||||
|
||||
// 从请求头中取出 token 这里需要和前端约定好把jwt放到请求头一个叫token的地方
|
||||
String token = request.getHeader("token");
|
||||
//他们校验的居然不是token串,而是去后台校验一个用户id ???
|
||||
String userId = request.getHeader("userId");
|
||||
log.info("获取到用户信息 userId : " + userId);
|
||||
User user = userService.lambdaQuery().eq(User::getUserId,userId).one();
|
||||
|
||||
//验证token
|
||||
if(JwtTool.verify(token)){
|
||||
if(user!=null){
|
||||
return true;
|
||||
}else{
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
response.setContentType("application/json; charset=utf-8");
|
||||
response.setHeader("Access-Control-Allow-Origin", "*");
|
||||
response.setHeader("Access-Control-Allow-Headers", "*");
|
||||
|
||||
Result result = new Result();
|
||||
result.setCode(CodeMsg.AUTH_FAILURE.getCode());
|
||||
result.setMsg(CodeMsg.AUTH_FAILURE.getMessage());
|
||||
if (token == null) {
|
||||
log.error("-------- 票据丢失,请重新登录");
|
||||
}else{
|
||||
log.error("-------- 票据认证失败,请重新登录");
|
||||
}
|
||||
PrintWriter out = null;
|
||||
try {
|
||||
out = response.getWriter();
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
package com.zbsz.init;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.context.ApplicationContextInitializer;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
|
||||
@Slf4j
|
||||
public class CustomInitializer implements ApplicationContextInitializer<ConfigurableApplicationContext> {
|
||||
@Override
|
||||
public void initialize(ConfigurableApplicationContext applicationContext) {
|
||||
log.info("----------- init 暂时不处理");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
package com.zbsz.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.common.entity.DicTarget;
|
||||
|
||||
public interface DicTargetMapper extends BaseMapper<DicTarget> {
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
package com.zbsz.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.common.entity.DicTarget;
|
||||
import com.zbsz.mapper.DicTargetMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class DicTargetService extends ServiceImpl<DicTargetMapper, DicTarget> {
|
||||
}
|
|
@ -1,7 +1,10 @@
|
|||
package com.zbsz.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.common.entity.User;
|
||||
import com.zbsz.mapper.UserMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
public interface UserService extends IService<User> {
|
||||
@Service
|
||||
public class UserService extends ServiceImpl<UserMapper, User> {
|
||||
}
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
package com.zbsz.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.common.entity.User;
|
||||
import com.zbsz.mapper.UserMapper;
|
||||
import com.zbsz.service.UserService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {
|
||||
}
|
|
@ -1,64 +0,0 @@
|
|||
package com.zbsz.tool;
|
||||
|
||||
import com.auth0.jwt.JWT;
|
||||
import com.auth0.jwt.JWTVerifier;
|
||||
import com.auth0.jwt.algorithms.Algorithm;
|
||||
import com.auth0.jwt.exceptions.JWTDecodeException;
|
||||
import com.auth0.jwt.interfaces.DecodedJWT;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public class JwtTool {
|
||||
private static final long EXPIRE_TIME = 15 * 60 * 60 * 1000;
|
||||
private static final String TOKEN_SECRET = "hp-xx040506070809-xxx-ppp";
|
||||
|
||||
/**
|
||||
* 校验token是否正确
|
||||
*
|
||||
* @param token 密钥
|
||||
* @return 是否正确
|
||||
*/
|
||||
public static boolean verify(String token) {
|
||||
try {
|
||||
Algorithm algorithm = Algorithm.HMAC256(TOKEN_SECRET);
|
||||
JWTVerifier verifier = JWT.require(algorithm).build();
|
||||
verifier.verify(token);
|
||||
return true;
|
||||
} catch (Exception exception) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得token中的信息无需secret解密也能获得
|
||||
* @return token中包含的用户名
|
||||
*/
|
||||
public static String getUsername(String token) {
|
||||
try {
|
||||
DecodedJWT jwt = JWT.decode(token);
|
||||
return jwt.getClaim("loginName").asString();
|
||||
} catch (JWTDecodeException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取token
|
||||
* @return jwt token
|
||||
*/
|
||||
public static String getToken(String username) {
|
||||
try {
|
||||
Date date = new Date(System.currentTimeMillis() + EXPIRE_TIME);//过期时间
|
||||
Algorithm algorithm = Algorithm.HMAC256(TOKEN_SECRET);//私钥及加密算法
|
||||
// 附带username,userId信息,生成签名
|
||||
return JWT.create().withAudience(username)
|
||||
.withIssuedAt(new Date()) //发行时间
|
||||
.withExpiresAt(date) //有效时间
|
||||
.withClaim("loginName", username)
|
||||
.sign(algorithm);
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -12,6 +12,9 @@ spring:
|
|||
mvc:
|
||||
pathmatch:
|
||||
matching-strategy: ant_path_matcher
|
||||
|
||||
custom-initializer: com.zbsz.init.CustomInitializer
|
||||
|
||||
mybatis-plus:
|
||||
configuration:
|
||||
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
||||
|
|
|
@ -3,14 +3,31 @@
|
|||
<configuration scan="true" scanPeriod="60 seconds" debug="false">
|
||||
<property name="log_dir" value="/szr/logs/zbsz" />
|
||||
<property name="maxHistory" value="30"/>
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<property name="logPattern" value="%d{yyyy-MM-dd HH:mm:ss} %-5level %logger -%msg%n"/>
|
||||
<appender name="stdout" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger -%msg%n</pattern>
|
||||
<pattern>${logPattern}</pattern>
|
||||
<charset>UTF-8</charset>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<appender name="ERROR" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<appender name="info" class="ch.qos.logback.core.rolling.RollingFileAppender" >
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<level>INFO</level>
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<onMismatch>DENY</onMismatch>
|
||||
</filter>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<fileNamePattern>${log_dir}/%d{yyyy-MM-dd}/info-log.log</fileNamePattern>
|
||||
<maxHistory>${maxHistory}</maxHistory>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<pattern>${logPattern}</pattern>
|
||||
<charset>UTF-8</charset>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<appender name="error" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<level>ERROR</level>
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
|
@ -21,31 +38,14 @@
|
|||
<maxHistory>${maxHistory}</maxHistory>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n</pattern>
|
||||
<pattern>${logPattern}</pattern>
|
||||
<charset>UTF-8</charset>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<appender name="INFO" class="ch.qos.logback.core.rolling.RollingFileAppender" >
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<level>INFO</level>
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<onMismatch>DENY</onMismatch>
|
||||
</filter>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<fileNamePattern>${log_dir}/%d{yyyy-MM-dd}/info-log.log
|
||||
</fileNamePattern>
|
||||
<maxHistory>${maxHistory}</maxHistory>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n</pattern>
|
||||
<charset>UTF-8</charset>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<root level="INFO" >
|
||||
<appender-ref ref="STDOUT" />
|
||||
<appender-ref ref="ERROR" />
|
||||
<appender-ref ref="INFO" />
|
||||
<root level="info">
|
||||
<appender-ref ref="stdout"/>
|
||||
<appender-ref ref="info" />
|
||||
<appender-ref ref="error"/>
|
||||
</root>
|
||||
</configuration>
|
||||
|
|
Loading…
Reference in New Issue