diff --git a/spzx-common/common-service/src/main/java/com/atguigu/config/ResourceConfiguration.java b/spzx-common/common-service/src/main/java/com/atguigu/config/ResourceConfiguration.java index d2999b0..af41f00 100644 --- a/spzx-common/common-service/src/main/java/com/atguigu/config/ResourceConfiguration.java +++ b/spzx-common/common-service/src/main/java/com/atguigu/config/ResourceConfiguration.java @@ -8,7 +8,7 @@ import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry @Slf4j public class ResourceConfiguration extends WebMvcConfiguration { protected void addResourceHandlers(ResourceHandlerRegistry registry) { - log.info("ResourceConfiguration===>设置静态资源映射......"); + log.info("ResourceConfiguration===>设置静态资源映射..."); registry.addResourceHandler("/doc.html").addResourceLocations("classpath:/META-INF/resources/"); registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/"); } diff --git a/spzx-common/common-service/src/main/java/com/atguigu/config/WebMvcConfiguration.java b/spzx-common/common-service/src/main/java/com/atguigu/config/WebMvcConfiguration.java index 97a9c3c..0998452 100644 --- a/spzx-common/common-service/src/main/java/com/atguigu/config/WebMvcConfiguration.java +++ b/spzx-common/common-service/src/main/java/com/atguigu/config/WebMvcConfiguration.java @@ -30,7 +30,7 @@ public class WebMvcConfiguration extends WebMvcConfigurationSupport { * @param registry 跨域注册表 */ protected void addCorsMappings(CorsRegistry registry) { - log.info("开始跨域注册表..."); + log.info("WebMvcConfiguration===>开始跨域注册表..."); registry.addMapping("/**")// 添加路径规则 .allowCredentials(true)// 是否允许在跨域的情况下传递Cookie .allowedOriginPatterns("*")// 允许请求来源的域规则 @@ -43,7 +43,7 @@ public class WebMvcConfiguration extends WebMvcConfigurationSupport { * @param registry InterceptorRegistry */ protected void addInterceptors(InterceptorRegistry registry) { - log.info("开始注册自定义拦截器..."); + log.info("WebMvcConfiguration===>开始注册自定义拦截器..."); // 需要拦截的 registry.addInterceptor(loginAuthInterceptor).addPathPatterns("/**") .excludePathPatterns(interceptorsProperties.getNoAuthUrls()); @@ -55,7 +55,7 @@ public class WebMvcConfiguration extends WebMvcConfigurationSupport { * @param converters 转换器 */ public void extendMessageConverters(List> converters) { - log.info("扩展消息转换器..."); + log.info("WebMvcConfiguration===>扩展消息转换器..."); // 创建一个消息转换器对象 MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter(); // 需要为消息转换器设置一个对象转换器,对象转换器可以将Java对象序列化为json数据 diff --git a/spzx-common/common-service/src/main/java/com/atguigu/exception/BunnyException.java b/spzx-common/common-service/src/main/java/com/atguigu/exception/BunnyException.java index 8848d1a..62732c9 100644 --- a/spzx-common/common-service/src/main/java/com/atguigu/exception/BunnyException.java +++ b/spzx-common/common-service/src/main/java/com/atguigu/exception/BunnyException.java @@ -11,7 +11,6 @@ import lombok.extern.slf4j.Slf4j; @ToString @Slf4j public class BunnyException extends RuntimeException { - Integer code;// 状态码 String message;// 描述信息 diff --git a/spzx-common/common-service/src/main/java/com/atguigu/handler/GlobalExceptionHandler.java b/spzx-common/common-service/src/main/java/com/atguigu/handler/GlobalExceptionHandler.java index d2dbe8c..202e696 100644 --- a/spzx-common/common-service/src/main/java/com/atguigu/handler/GlobalExceptionHandler.java +++ b/spzx-common/common-service/src/main/java/com/atguigu/handler/GlobalExceptionHandler.java @@ -20,7 +20,7 @@ public class GlobalExceptionHandler { @ExceptionHandler(BunnyException.class) @ResponseBody public Result exceptionHandler(BunnyException exception) { - log.error("自定义异常信息:{}", exception.getMessage()); + log.error("GlobalExceptionHandler===>自定义异常信息:{}", exception.getMessage()); return Result.error(exception.getCode(), exception.getMessage()); } @@ -28,7 +28,7 @@ public class GlobalExceptionHandler { @ExceptionHandler(RuntimeException.class) @ResponseBody public Result exceptionHandler(RuntimeException exception) { - log.error("运行时异常信息:{}", exception.getMessage()); + log.error("GlobalExceptionHandler===>运行时异常信息:{}", exception.getMessage()); return Result.error(500, "出错了啦"); } @@ -36,7 +36,7 @@ public class GlobalExceptionHandler { @ExceptionHandler(Exception.class) @ResponseBody public Result error(Exception exception) { - log.error("系统异常信息:{}", exception.getMessage()); + log.error("GlobalExceptionHandler===>系统异常信息:{}", exception.getMessage()); return Result.error(exception.getMessage()); } @@ -44,14 +44,15 @@ public class GlobalExceptionHandler { @ExceptionHandler(ArithmeticException.class) @ResponseBody public Result error(ArithmeticException exception) { - log.error("特定异常信息:{}", exception.getMessage()); + log.error("GlobalExceptionHandler===>特定异常信息:{}", exception.getMessage()); return Result.error(null, exception.getMessage()); } // spring security异常 @ExceptionHandler(AccessDeniedException.class) @ResponseBody - public Result error(AccessDeniedException e) throws AccessDeniedException { + public Result error(AccessDeniedException exception) throws AccessDeniedException { + log.error("GlobalExceptionHandler===>spring security异常:{}", exception.getMessage()); return Result.error(ResultCodeEnum.PERMISSION); } @@ -59,7 +60,7 @@ public class GlobalExceptionHandler { @ExceptionHandler(SQLIntegrityConstraintViolationException.class) @ResponseBody public Result exceptionHandler(SQLIntegrityConstraintViolationException exception) { - log.error("处理SQL异常:{}", exception.getMessage()); + log.error("GlobalExceptionHandler===>处理SQL异常:{}", exception.getMessage()); String message = exception.getMessage(); if (message.contains("Duplicate entry")) { // 截取用户名 diff --git a/spzx-common/common-service/src/main/java/com/atguigu/interceptor/LoginAuthInterceptor.java b/spzx-common/common-service/src/main/java/com/atguigu/interceptor/LoginAuthInterceptor.java index 1cb2fe2..73af3e9 100644 --- a/spzx-common/common-service/src/main/java/com/atguigu/interceptor/LoginAuthInterceptor.java +++ b/spzx-common/common-service/src/main/java/com/atguigu/interceptor/LoginAuthInterceptor.java @@ -3,8 +3,6 @@ package com.atguigu.interceptor; import com.alibaba.fastjson.JSON; import com.atguigu.context.BaseContext; import com.atguigu.spzx.model.entity.system.SysUser; -import com.atguigu.spzx.model.vo.result.Result; -import com.atguigu.spzx.model.vo.result.ResultCodeEnum; import com.atguigu.utils.InterceptorUtil; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; @@ -18,8 +16,6 @@ import org.springframework.lang.Nullable; import org.springframework.web.method.HandlerMethod; import org.springframework.web.servlet.HandlerInterceptor; -import java.io.IOException; -import java.io.PrintWriter; import java.util.concurrent.TimeUnit; @Configuration @@ -52,7 +48,7 @@ public class LoginAuthInterceptor implements HandlerInterceptor { // 将用户信息放到ThreadLocal中 SysUser sysUser = JSON.parseObject(userinfoString, SysUser.class); BaseContext.setSysUser(sysUser); - + // 更新Redis过期时间 redisTemplate.expire(token, 7, TimeUnit.DAYS); @@ -65,19 +61,6 @@ public class LoginAuthInterceptor implements HandlerInterceptor { */ @Override public void afterCompletion(@NonNull HttpServletRequest request, @NonNull HttpServletResponse response, @NonNull Object handler, @Nullable Exception ex) throws Exception { - log.info("删除ThreadLocal..."); BaseContext.removeSysUser(); } - - // 响应208状态码给前端 - private void responseNoLoginInfo(HttpServletResponse response) { - Result result = Result.error(ResultCodeEnum.LOGIN_AUTH); - response.setCharacterEncoding("UTF-8"); - response.setContentType("text/html; charset=utf-8"); - try (PrintWriter writer = response.getWriter()) { - writer.print(JSON.toJSONString(result)); - } catch (IOException e) { - log.error("出错了===>{}", e.getMessage()); - } - } } diff --git a/spzx-common/common-service/target/classes/com/atguigu/config/RedisConfiguration.class b/spzx-common/common-service/target/classes/com/atguigu/config/RedisConfiguration.class index 0fd0c6e..7b1ee25 100644 Binary files a/spzx-common/common-service/target/classes/com/atguigu/config/RedisConfiguration.class and b/spzx-common/common-service/target/classes/com/atguigu/config/RedisConfiguration.class differ diff --git a/spzx-common/common-service/target/classes/com/atguigu/config/ResourceConfiguration.class b/spzx-common/common-service/target/classes/com/atguigu/config/ResourceConfiguration.class index 76c9f3f..4f4fcc7 100644 Binary files a/spzx-common/common-service/target/classes/com/atguigu/config/ResourceConfiguration.class and b/spzx-common/common-service/target/classes/com/atguigu/config/ResourceConfiguration.class differ diff --git a/spzx-common/common-service/target/classes/com/atguigu/config/WebMvcConfiguration.class b/spzx-common/common-service/target/classes/com/atguigu/config/WebMvcConfiguration.class index 5b7146f..8b293ef 100644 Binary files a/spzx-common/common-service/target/classes/com/atguigu/config/WebMvcConfiguration.class and b/spzx-common/common-service/target/classes/com/atguigu/config/WebMvcConfiguration.class differ diff --git a/spzx-common/common-service/target/classes/com/atguigu/exception/BunnyException.class b/spzx-common/common-service/target/classes/com/atguigu/exception/BunnyException.class index bfc7256..4aa49a6 100644 Binary files a/spzx-common/common-service/target/classes/com/atguigu/exception/BunnyException.class and b/spzx-common/common-service/target/classes/com/atguigu/exception/BunnyException.class differ diff --git a/spzx-common/common-service/target/classes/com/atguigu/handler/GlobalExceptionHandler.class b/spzx-common/common-service/target/classes/com/atguigu/handler/GlobalExceptionHandler.class index 471382f..77fa4b2 100644 Binary files a/spzx-common/common-service/target/classes/com/atguigu/handler/GlobalExceptionHandler.class and b/spzx-common/common-service/target/classes/com/atguigu/handler/GlobalExceptionHandler.class differ diff --git a/spzx-common/common-service/target/classes/com/atguigu/interceptor/LoginAuthInterceptor.class b/spzx-common/common-service/target/classes/com/atguigu/interceptor/LoginAuthInterceptor.class index 0a34552..09fccf0 100644 Binary files a/spzx-common/common-service/target/classes/com/atguigu/interceptor/LoginAuthInterceptor.class and b/spzx-common/common-service/target/classes/com/atguigu/interceptor/LoginAuthInterceptor.class differ diff --git a/spzx-common/common-util/pom.xml b/spzx-common/common-util/pom.xml index 75ccf7e..a379e71 100644 --- a/spzx-common/common-util/pom.xml +++ b/spzx-common/common-util/pom.xml @@ -24,11 +24,6 @@ spzx-model 1.0-SNAPSHOT - - - - - org.springframework.boot diff --git a/spzx-manager/Dockerfile b/spzx-manager/Dockerfile new file mode 100644 index 0000000..421b7e4 --- /dev/null +++ b/spzx-manager/Dockerfile @@ -0,0 +1,20 @@ +FROM openjdk:18 + +#系统编码 +ENV LANG=C.UTF-8 LC_ALL=C.UTF-8 + +# 设置时区,构建镜像时执行的命令 +RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime +RUN echo "Asia/Shanghai" > /etc/timezone + +# 设定工作目录 +WORKDIR /home/bunny + +# 复制jar包 +COPY target/sky-server-1.0-SNAPSHOT.jar /home/bunny/app.jar + +#启动容器时的进程 +ENTRYPOINT ["java","-jar","/home/bunny/app.jar"] + +#暴露 8080 端口 +EXPOSE 8080 \ No newline at end of file diff --git a/spzx-manager/src/main/resources/application.yml b/spzx-manager/src/main/resources/application.yml index 2dcaf49..6ee6c3b 100644 --- a/spzx-manager/src/main/resources/application.yml +++ b/spzx-manager/src/main/resources/application.yml @@ -25,7 +25,6 @@ logging: com.atguigu.mapper: debug com.atguigu.controller: info com.atguigu.service: info - com.github.pagehelper: debug pattern: dateformat: HH:mm:ss:SSS file: diff --git a/spzx-manager/target/classes/application.yml b/spzx-manager/target/classes/application.yml index 2dcaf49..6ee6c3b 100644 --- a/spzx-manager/target/classes/application.yml +++ b/spzx-manager/target/classes/application.yml @@ -25,7 +25,6 @@ logging: com.atguigu.mapper: debug com.atguigu.controller: info com.atguigu.service: info - com.github.pagehelper: debug pattern: dateformat: HH:mm:ss:SSS file: