Commit 329413a2 by tyfanchz

jackson配置修改

1 parent 26438a54
//package com.glsx.admin.exception;
//
//import java.util.List;
//import java.util.concurrent.TimeoutException;
//import com.alibaba.fastjson.JSON;
//import com.alibaba.fastjson.JSONObject;
//import com.glsx.plat.common.utils.StringUtils;
//import com.glsx.plat.core.web.R;
//import com.netflix.hystrix.exception.HystrixRuntimeException;
//import feign.FeignException;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.validation.BindException;
//import org.springframework.validation.FieldError;
//import org.springframework.web.bind.MethodArgumentNotValidException;
//import org.springframework.web.bind.ServletRequestBindingException;
//import org.springframework.web.bind.annotation.ExceptionHandler;
//import org.springframework.web.bind.annotation.RestControllerAdvice;
//
///**
// * <p>Description:
// * <p>Project: chejia-smart
// *
// * @author wbh
// * @date 2021-03-16
// */
//@Slf4j
//@RestControllerAdvice
//public class GlobalExceptionHandler {
// @ExceptionHandler({ChejiaBusinessException.class})
// public R handleBusinessException(ChejiaBusinessException e) {
// log.error("!!!! 业务异常", e);
// return R.error(e.getCode(), e.getMessage());
// }
//
// @ExceptionHandler({ServletRequestBindingException.class, MethodArgumentNotValidException.class,
// BindException.class})
// public R handleBindException(Exception e) {
// log.error("!!!! 参数错误", e);
// if ((e instanceof MethodArgumentNotValidException) || (e instanceof BindException)) {
// List<FieldError> errorList;
// if (e instanceof MethodArgumentNotValidException) {
// MethodArgumentNotValidException ex = (MethodArgumentNotValidException) e;
// errorList = ex.getBindingResult().getFieldErrors();
// } else {
// BindException ex = (BindException) e;
// errorList = ex.getFieldErrors();
// }
// StringBuffer messageSb = new StringBuffer();
// for (FieldError error : errorList) {
// String fieldMessage = String.format("%s: %s, ",
// error.getField(), error.getDefaultMessage());
// messageSb.append(fieldMessage);
// }
// return R.error(ResultEnum.PARAM_ERROR.getCode(),
// messageSb.toString().replaceAll(", +$", ""));
// } else {
// return R.error(ResultEnum.PARAM_ERROR.getCode(), ResultEnum.PARAM_ERROR.getMessage());
// }
// }
//
// @ExceptionHandler({HystrixRuntimeException.class})
// public R handleHystrixException(HystrixRuntimeException e) {
// Throwable cause = e.getCause();
// if (cause instanceof FeignException) {
// FeignException feignException = (FeignException) cause;
// return this.handleFeignException(feignException);
// } else if (cause instanceof TimeoutException) {
// log.error("!!!! 服务调用超时", e);
// return R.error(ResultEnum.REMOTE_SERVER_TIME_OUT.getCode(),
// ResultEnum.REMOTE_SERVER_TIME_OUT.getMessage());
// } else {
// log.error("!!!! Hystrix熔断错误", e);
// return R.error(ResultEnum.ERROR.getCode(), ResultEnum.ERROR.getMessage());
// }
// }
//
// @ExceptionHandler({FeignException.class})
// public R handleFeignException(FeignException e) {
// log.error("!!!! 远程服务错误", e);
// String respMessage;
// if (StringUtils.isNotBlank(e.contentUTF8())) {
// JSONObject respObj = JSON.parseObject(e.contentUTF8());
// respMessage = respObj.getString("message");
// } else {
// respMessage = "";
// }
// int code = ResultEnum.REMOTE_SERVICE_ERROR.getCode();
// String message = StringUtils.isBlank(respMessage)
// ? ResultEnum.REMOTE_SERVICE_ERROR.getMessage() : respMessage;
// return R.error(code, message);
// }
//
// @ExceptionHandler(Exception.class)
// public R handleException(Exception e) {
// log.error("!!!! 未知异常", e);
// return R.error(ResultEnum.ERROR.getCode(), ResultEnum.ERROR.getMessage());
// }
//}
//package com.glsx.admin.filter;
//
//import javax.servlet.Filter;
//import javax.servlet.FilterChain;
//import javax.servlet.ServletException;
//import javax.servlet.ServletRequest;
//import javax.servlet.ServletResponse;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.io.IOException;
//import java.util.Enumeration;
//import com.glsx.plat.common.utils.StringUtils;
//import org.springframework.http.HttpHeaders;
//import org.springframework.http.HttpMethod;
//import org.springframework.stereotype.Component;
//
///**
// * <p>Description: 跨域配置
// * <p>Project: chejia-smart
// *
// * @author wbh
// * @date 2021-03-18
// */
//@Component
//public class CorsFilter implements Filter {
// @Override
// public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
// throws IOException, ServletException {
// HttpServletRequest httpRequest = (HttpServletRequest) request;
// HttpServletResponse httpResponse = (HttpServletResponse) response;
//
// StringBuffer headersSb = new StringBuffer();
// Enumeration<String> headerNames = httpRequest.getHeaderNames();
// while (headerNames.hasMoreElements()) {
// headersSb.append(headerNames.nextElement()).append(", ");
// }
// if (!StringUtils.containsIgnoreCase(headersSb, HttpHeaders.CONTENT_TYPE)) {
// headersSb.append(HttpHeaders.CONTENT_TYPE).append(", ");
// }
// if (!StringUtils.containsIgnoreCase(headersSb, HttpHeaders.AUTHORIZATION)) {
// headersSb.append(HttpHeaders.AUTHORIZATION).append(", ");
// }
// httpResponse.addHeader(HttpHeaders.ACCESS_CONTROL_ALLOW_HEADERS,
// headersSb.toString().replaceAll(", +$", ""));
//
// httpResponse.addHeader(HttpHeaders.ACCESS_CONTROL_ALLOW_CREDENTIALS, "true");
// httpResponse.addHeader(HttpHeaders.ACCESS_CONTROL_ALLOW_ORIGIN,
// httpRequest.getHeader(HttpHeaders.ORIGIN));
// httpResponse.addHeader(HttpHeaders.ACCESS_CONTROL_ALLOW_METHODS,
// httpRequest.getMethod());
// httpResponse.addHeader(HttpHeaders.ACCESS_CONTROL_EXPOSE_HEADERS, "*");
// httpResponse.addHeader(HttpHeaders.ACCESS_CONTROL_MAX_AGE, "18000L");
//
// // 放行预检请求(preflight requests)
// if (httpRequest.getMethod().equalsIgnoreCase(HttpMethod.OPTIONS.toString())) {
// httpResponse.setStatus(HttpServletResponse.SC_OK);
// httpResponse.getWriter().println("OK");
// return;
// }
//
// chain.doFilter(request, response);
// }
//}
...@@ -5,6 +5,10 @@ server.servlet.context-path=/smartAdmin ...@@ -5,6 +5,10 @@ server.servlet.context-path=/smartAdmin
#\u6307\u5B9Adate\u8F93\u51FA\u683C\u5F0F\u4E3Ayyyy-MM-dd HH:mm:ss #\u6307\u5B9Adate\u8F93\u51FA\u683C\u5F0F\u4E3Ayyyy-MM-dd HH:mm:ss
spring.jackson.date-format=yyyy-MM-dd HH:mm:ss spring.jackson.date-format=yyyy-MM-dd HH:mm:ss
spring.jackson.time-zone=GMT+8 spring.jackson.time-zone=GMT+8
spring.jackson.serialization.write-dates-as-timestamps=false
spring.jackson.serialization.fail-on-empty-beans=false
spring.jackson.deserialization.fail-on-ignored-properties=false
spring.jackson.deserialization.fail-on-unknown-properties=false
server.tomcat.uri-encoding=UTF-8 server.tomcat.uri-encoding=UTF-8
spring.messages.encoding=UTF-8 spring.messages.encoding=UTF-8
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!