diff --git a/epmet-admin/epmet-admin-client/src/main/java/com/epmet/feign/EpmetAdminOpenFeignClient.java b/epmet-admin/epmet-admin-client/src/main/java/com/epmet/feign/EpmetAdminOpenFeignClient.java index e1b48a9186..65b73cdad3 100644 --- a/epmet-admin/epmet-admin-client/src/main/java/com/epmet/feign/EpmetAdminOpenFeignClient.java +++ b/epmet-admin/epmet-admin-client/src/main/java/com/epmet/feign/EpmetAdminOpenFeignClient.java @@ -3,14 +3,14 @@ package com.epmet.feign; import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.utils.Result; import com.epmet.dto.result.CorsConfigResultDTO; -import com.epmet.feign.fallback.EpmetAdminOpenFeignClientFallback; +import com.epmet.feign.fallback.EpmetAdminOpenFeignClientFallbackFactory; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.PostMapping; import java.util.List; -@FeignClient(name = ServiceConstant.EPMET_ADMIN_SERVER, fallback = EpmetAdminOpenFeignClientFallback.class) -//@FeignClient(name = ServiceConstant.EPMET_ADMIN_SERVER, fallback = EpmetAdminOpenFeignClientFallback.class, url = "localhost:8082") +@FeignClient(name = ServiceConstant.EPMET_ADMIN_SERVER, fallbackFactory = EpmetAdminOpenFeignClientFallbackFactory.class) +//@FeignClient(name = ServiceConstant.EPMET_ADMIN_SERVER, fallbackFactory = EpmetAdminOpenFeignClientFallbackFactory.class, url = "localhost:8082") public interface EpmetAdminOpenFeignClient { /** diff --git a/epmet-admin/epmet-admin-client/src/main/java/com/epmet/feign/fallback/EpmetAdminOpenFeignClientFallback.java b/epmet-admin/epmet-admin-client/src/main/java/com/epmet/feign/fallback/EpmetAdminOpenFeignClientFallback.java index 72edce3446..69d8a45bbc 100644 --- a/epmet-admin/epmet-admin-client/src/main/java/com/epmet/feign/fallback/EpmetAdminOpenFeignClientFallback.java +++ b/epmet-admin/epmet-admin-client/src/main/java/com/epmet/feign/fallback/EpmetAdminOpenFeignClientFallback.java @@ -9,7 +9,7 @@ import org.springframework.stereotype.Component; import java.util.List; -@Component +//@Component public class EpmetAdminOpenFeignClientFallback implements EpmetAdminOpenFeignClient { @Override public Result> list() { diff --git a/epmet-admin/epmet-admin-client/src/main/java/com/epmet/feign/fallback/EpmetAdminOpenFeignClientFallbackFactory.java b/epmet-admin/epmet-admin-client/src/main/java/com/epmet/feign/fallback/EpmetAdminOpenFeignClientFallbackFactory.java new file mode 100644 index 0000000000..2cc1398135 --- /dev/null +++ b/epmet-admin/epmet-admin-client/src/main/java/com/epmet/feign/fallback/EpmetAdminOpenFeignClientFallbackFactory.java @@ -0,0 +1,20 @@ +package com.epmet.feign.fallback; + +import com.epmet.commons.tools.exception.ExceptionUtils; +import com.epmet.feign.EpmetAdminOpenFeignClient; +import feign.hystrix.FallbackFactory; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +@Component +@Slf4j +public class EpmetAdminOpenFeignClientFallbackFactory implements FallbackFactory { + + private EpmetAdminOpenFeignClientFallback fallback = new EpmetAdminOpenFeignClientFallback(); + + @Override + public EpmetAdminOpenFeignClient create(Throwable cause) { + log.error(String.format("FeignClient调用发生异常,异常信息:%s", ExceptionUtils.getThrowableErrorStackTrace(cause))); + return fallback; + } +} diff --git a/epmet-admin/epmet-admin-server/src/main/java/com/epmet/AdminApplication.java b/epmet-admin/epmet-admin-server/src/main/java/com/epmet/AdminApplication.java index ea0ca31624..ea570175ef 100644 --- a/epmet-admin/epmet-admin-server/src/main/java/com/epmet/AdminApplication.java +++ b/epmet-admin/epmet-admin-server/src/main/java/com/epmet/AdminApplication.java @@ -10,6 +10,7 @@ package com.epmet; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.web.servlet.ServletComponentScan; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.cloud.openfeign.EnableFeignClients; @@ -22,6 +23,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients; @SpringBootApplication @EnableDiscoveryClient @EnableFeignClients +@ServletComponentScan public class AdminApplication { public static void main(String[] args) { diff --git a/epmet-auth/src/main/java/com/epmet/AuthApplication.java b/epmet-auth/src/main/java/com/epmet/AuthApplication.java index 51635f759e..2c14a7792b 100644 --- a/epmet-auth/src/main/java/com/epmet/AuthApplication.java +++ b/epmet-auth/src/main/java/com/epmet/AuthApplication.java @@ -10,6 +10,7 @@ package com.epmet; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.web.servlet.ServletComponentScan; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.cloud.openfeign.EnableFeignClients; @@ -22,6 +23,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients; @SpringBootApplication @EnableDiscoveryClient @EnableFeignClients +@ServletComponentScan // 开启Servlet容器扫描,扫描@WebFilter等注解 public class AuthApplication { public static void main(String[] args) { diff --git a/epmet-auth/src/main/java/com/epmet/controller/AuthController.java b/epmet-auth/src/main/java/com/epmet/controller/AuthController.java index 50bd9fc267..52f06c9c25 100644 --- a/epmet-auth/src/main/java/com/epmet/controller/AuthController.java +++ b/epmet-auth/src/main/java/com/epmet/controller/AuthController.java @@ -15,7 +15,9 @@ import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.AssertUtils; import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.dto.AuthorizationDTO; +import com.epmet.dto.CustomerStaffDTO; import com.epmet.dto.LoginDTO; +import com.epmet.feign.EpmetUserOpenFeignClient; import com.epmet.service.AuthService; import com.epmet.service.CaptchaService; import com.epmet.service.ResourceService; diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/aspect/ThreadLocalInitAspect.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/aspect/ThreadLocalInitAspect.java index 2e070b1817..7ac89e63fc 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/aspect/ThreadLocalInitAspect.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/aspect/ThreadLocalInitAspect.java @@ -1,45 +1,45 @@ -/** - * Copyright (c) 2018 人人开源 All rights reserved. - *

- * https://www.renren.io - *

- * 版权所有,侵权必究! - */ - -package com.epmet.commons.tools.aspect; - -import com.epmet.commons.tools.constant.ThreadLocalConstant; -import com.epmet.commons.tools.dto.form.LoginUserInfoResultDTO; -import com.epmet.commons.tools.exception.ExceptionUtils; -import org.aspectj.lang.JoinPoint; -import org.aspectj.lang.annotation.Aspect; -import org.aspectj.lang.annotation.Before; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.core.annotation.Order; -import org.springframework.stereotype.Component; - -/** - * 每次请求,清理ThreadLocal线程中的变量 - * @Author wxz - * @Description - * @Date 2020/4/23 16:16 - **/ -@Aspect -@Component -@Order(1) -public class ThreadLocalInitAspect { - - private static final Logger log = LoggerFactory.getLogger(ThreadLocalInitAspect.class); - - @Before(value = "execution(* com.epmet.controller.*Controller*.*(..)) ") - public void before(JoinPoint point) throws Throwable { - // 清理权限过滤中的变量残留 - try { - ThreadLocalConstant.sqlFilter.remove(); - ThreadLocalConstant.requirePermissionTl.remove(); - } catch (Exception e) { - log.error("清理sqlFilter缓存失败:{}", ExceptionUtils.getErrorStackTrace(e)); - } - } -} +///** +// * Copyright (c) 2018 人人开源 All rights reserved. +// *

+// * https://www.renren.io +// *

+// * 版权所有,侵权必究! +// */ +// +//package com.epmet.commons.tools.aspect; +// +//import com.epmet.commons.tools.constant.ThreadLocalConstant; +//import com.epmet.commons.tools.dto.form.LoginUserInfoResultDTO; +//import com.epmet.commons.tools.exception.ExceptionUtils; +//import org.aspectj.lang.JoinPoint; +//import org.aspectj.lang.annotation.Aspect; +//import org.aspectj.lang.annotation.Before; +//import org.slf4j.Logger; +//import org.slf4j.LoggerFactory; +//import org.springframework.core.annotation.Order; +//import org.springframework.stereotype.Component; +// +///** +// * 每次请求,清理ThreadLocal线程中的变量(已废弃,改用GlobalFilter) +// * @Author wxz +// * @Description +// * @Date 2020/4/23 16:16 +// **/ +//@Aspect +//@Component +//@Order(1) +//public class ThreadLocalInitAspect { +// +// private static final Logger log = LoggerFactory.getLogger(ThreadLocalInitAspect.class); +// +// @Before(value = "execution(* com.epmet.controller.*Controller*.*(..)) ") +// public void before(JoinPoint point) throws Throwable { +// // 清理权限过滤中的变量残留 +// try { +// ThreadLocalConstant.sqlFilter.remove(); +// ThreadLocalConstant.requirePermissionTl.remove(); +// } catch (Exception e) { +// log.error("清理sqlFilter缓存失败:{}", ExceptionUtils.getErrorStackTrace(e)); +// } +// } +//} diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/filter/GlobalFilter.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/filter/GlobalFilter.java new file mode 100644 index 0000000000..fe3dc8a3e9 --- /dev/null +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/filter/GlobalFilter.java @@ -0,0 +1,30 @@ +package com.epmet.commons.tools.filter; + +import com.epmet.commons.tools.constant.ThreadLocalConstant; + +import javax.servlet.*; +import javax.servlet.annotation.WebFilter; +import java.io.IOException; + +/** + * @Description 全局过滤器,可在请求结束的时候清除线程变量残留 + * @author wxz + * @date 2021.07.19 10:19:24 +*/ +@WebFilter(value = "/*") +public class GlobalFilter implements Filter { + + @Override + public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { + try { + filterChain.doFilter(servletRequest, servletResponse); + } catch (Throwable e) { + throw e; + } finally { + // 清除线程变量残留 + ThreadLocalConstant.sqlFilter.remove(); + ThreadLocalConstant.requirePermissionTl.remove(); + ThreadLocalConstant.requestParam.remove(); + } + } +} \ No newline at end of file diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/filter/LogMsgSendFilter.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/filter/LogMsgSendFilter.java index f6d39b325d..ffadf837b3 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/filter/LogMsgSendFilter.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/filter/LogMsgSendFilter.java @@ -205,7 +205,7 @@ public class LogMsgSendFilter extends LevelFilter { return slashMatcher.start(); } catch (Exception e) { logger.warn("getCharacterPosition no matche", e); - return 0; + return string.length(); } } diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/security/config/WebMvcConfig.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/security/config/WebMvcConfig.java index 549530747b..d1af449333 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/security/config/WebMvcConfig.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/security/config/WebMvcConfig.java @@ -66,7 +66,7 @@ public class WebMvcConfig implements WebMvcConfigurer { //日期格式转换 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - mapper.setDateFormat(new SimpleDateFormat(DateUtils.DATE_TIME_PATTERN_END_WITH_MINUTE)); + mapper.setDateFormat(new SimpleDateFormat(DateUtils.DATE_TIME_PATTERN)); mapper.setTimeZone(TimeZone.getTimeZone("GMT+8")); //Long类型转String类型 diff --git a/epmet-gateway/src/main/java/com/epmet/GatewayApplication.java b/epmet-gateway/src/main/java/com/epmet/GatewayApplication.java index 5c8d111813..5a86194ea7 100644 --- a/epmet-gateway/src/main/java/com/epmet/GatewayApplication.java +++ b/epmet-gateway/src/main/java/com/epmet/GatewayApplication.java @@ -11,6 +11,7 @@ package com.epmet; import com.epmet.commons.tools.aspect.ServletExceptionHandler; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.web.servlet.ServletComponentScan; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.cloud.openfeign.EnableFeignClients; import org.springframework.context.annotation.ComponentScan; @@ -25,6 +26,7 @@ import org.springframework.context.annotation.FilterType; @SpringBootApplication() @EnableDiscoveryClient @EnableFeignClients +//@ServletComponentScan @ComponentScan(basePackages = {"com.epmet.*"}, excludeFilters = @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = {ServletExceptionHandler.class})) public class GatewayApplication { diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/DataAggregatorApplication.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/DataAggregatorApplication.java index 791cf0b415..5e8d7c4788 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/DataAggregatorApplication.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/DataAggregatorApplication.java @@ -3,12 +3,14 @@ package com.epmet; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; +import org.springframework.boot.web.servlet.ServletComponentScan; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.cloud.openfeign.EnableFeignClients; @SpringBootApplication(scanBasePackages = {"com.epmet"}, exclude = {DataSourceAutoConfiguration.class}) @EnableDiscoveryClient @EnableFeignClients +@ServletComponentScan public class DataAggregatorApplication { public static void main(String[] args) { SpringApplication.run(DataAggregatorApplication.class, args); diff --git a/epmet-module/data-report/data-report-client/src/main/java/com/epmet/feign/DataReportOpenFeignClient.java b/epmet-module/data-report/data-report-client/src/main/java/com/epmet/feign/DataReportOpenFeignClient.java index d3466126a4..b93bcc24f2 100644 --- a/epmet-module/data-report/data-report-client/src/main/java/com/epmet/feign/DataReportOpenFeignClient.java +++ b/epmet-module/data-report/data-report-client/src/main/java/com/epmet/feign/DataReportOpenFeignClient.java @@ -4,6 +4,7 @@ import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.utils.Result; import com.epmet.dto.result.plugins.AgencyNodeDTO; import com.epmet.feign.impl.DataReportOpenFeignClientFallBack; +import com.epmet.feign.impl.DataReportOpenFeignClientFallBackFactory; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; @@ -14,8 +15,8 @@ import org.springframework.web.bind.annotation.PathVariable; * @author yinzuomei@elink-cn.com * @date 2021/2/3 22:05 */ -// @FeignClient(name = ServiceConstant.DATA_REPORT_SERVER, fallback = DataReportOpenFeignClientFallBack.class,url = "localhost:8109") -@FeignClient(name = ServiceConstant.DATA_REPORT_SERVER, fallback = DataReportOpenFeignClientFallBack.class) + //@FeignClient(name = ServiceConstant.DATA_REPORT_SERVER, fallbackFactory = DataReportOpenFeignClientFallBackFactory.class,url = "localhost:8109") +@FeignClient(name = ServiceConstant.DATA_REPORT_SERVER, fallbackFactory = DataReportOpenFeignClientFallBackFactory.class) public interface DataReportOpenFeignClient { /** * @param agencyId diff --git a/epmet-module/data-report/data-report-client/src/main/java/com/epmet/feign/impl/DataReportOpenFeignClientFallBack.java b/epmet-module/data-report/data-report-client/src/main/java/com/epmet/feign/impl/DataReportOpenFeignClientFallBack.java index 64a9f66d0f..6fc231e853 100644 --- a/epmet-module/data-report/data-report-client/src/main/java/com/epmet/feign/impl/DataReportOpenFeignClientFallBack.java +++ b/epmet-module/data-report/data-report-client/src/main/java/com/epmet/feign/impl/DataReportOpenFeignClientFallBack.java @@ -7,7 +7,7 @@ import com.epmet.dto.result.plugins.AgencyNodeDTO; import com.epmet.feign.DataReportOpenFeignClient; import org.springframework.stereotype.Component; -@Component +//@Component public class DataReportOpenFeignClientFallBack implements DataReportOpenFeignClient { /** * @param agencyId diff --git a/epmet-module/data-report/data-report-client/src/main/java/com/epmet/feign/impl/DataReportOpenFeignClientFallBackFactory.java b/epmet-module/data-report/data-report-client/src/main/java/com/epmet/feign/impl/DataReportOpenFeignClientFallBackFactory.java new file mode 100644 index 0000000000..c3d0b0ab84 --- /dev/null +++ b/epmet-module/data-report/data-report-client/src/main/java/com/epmet/feign/impl/DataReportOpenFeignClientFallBackFactory.java @@ -0,0 +1,19 @@ +package com.epmet.feign.impl; + +import com.epmet.commons.tools.exception.ExceptionUtils; +import com.epmet.feign.DataReportOpenFeignClient; +import feign.hystrix.FallbackFactory; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +@Component +@Slf4j +public class DataReportOpenFeignClientFallBackFactory implements FallbackFactory { + private DataReportOpenFeignClientFallBack fallback = new DataReportOpenFeignClientFallBack(); + + @Override + public DataReportOpenFeignClient create(Throwable cause) { + log.error(String.format("FeignClient调用发生异常,异常信息:%s", ExceptionUtils.getThrowableErrorStackTrace(cause))); + return fallback; + } +} diff --git a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/DataReportApplication.java b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/DataReportApplication.java index cee0ed9096..3fccfa8b6e 100644 --- a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/DataReportApplication.java +++ b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/DataReportApplication.java @@ -2,6 +2,7 @@ package com.epmet; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.web.servlet.ServletComponentScan; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.cloud.openfeign.EnableFeignClients; import org.springframework.scheduling.annotation.EnableAsync; @@ -10,6 +11,7 @@ import org.springframework.scheduling.annotation.EnableAsync; @EnableDiscoveryClient @EnableFeignClients @EnableAsync +@ServletComponentScan public class DataReportApplication { public static void main(String[] args) { SpringApplication.run(DataReportApplication.class, args); diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/feign/impl/DataStatisticalOpenFeignClientFallBackFactory.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/feign/impl/DataStatisticalOpenFeignClientFallBackFactory.java index 70768329c8..84b630ea50 100644 --- a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/feign/impl/DataStatisticalOpenFeignClientFallBackFactory.java +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/feign/impl/DataStatisticalOpenFeignClientFallBackFactory.java @@ -14,7 +14,7 @@ public class DataStatisticalOpenFeignClientFallBackFactory implements FallbackFa @Override public DataStatisticalOpenFeignClient create(Throwable cause) { - log.error(ExceptionUtils.getThrowableErrorStackTrace(cause));//自己写的工具类 + log.error(String.format("FeignClient调用发生异常,异常信息:%s", ExceptionUtils.getThrowableErrorStackTrace(cause))); return fallback; } } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/DataStatsApplication.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/DataStatsApplication.java index 3b93ce39a3..4a572b4889 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/DataStatsApplication.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/DataStatsApplication.java @@ -3,6 +3,7 @@ package com.epmet; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; +import org.springframework.boot.web.servlet.ServletComponentScan; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.cloud.openfeign.EnableFeignClients; import org.springframework.scheduling.annotation.EnableAsync; @@ -11,6 +12,7 @@ import org.springframework.scheduling.annotation.EnableAsync; @EnableFeignClients @SpringBootApplication (exclude = {DataSourceAutoConfiguration.class}) @EnableAsync +@ServletComponentScan public class DataStatsApplication { public static void main(String[] args) { diff --git a/epmet-module/epmet-activiti/epmet-activiti-server/src/main/java/com/epmet/ActivitiApplication.java b/epmet-module/epmet-activiti/epmet-activiti-server/src/main/java/com/epmet/ActivitiApplication.java index e449ae4050..46ee097f8d 100644 --- a/epmet-module/epmet-activiti/epmet-activiti-server/src/main/java/com/epmet/ActivitiApplication.java +++ b/epmet-module/epmet-activiti/epmet-activiti-server/src/main/java/com/epmet/ActivitiApplication.java @@ -10,6 +10,7 @@ package com.epmet; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.web.servlet.ServletComponentScan; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.cloud.openfeign.EnableFeignClients; @@ -25,6 +26,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients; }) @EnableDiscoveryClient @EnableFeignClients +@ServletComponentScan public class ActivitiApplication { public static void main(String[] args) { diff --git a/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/feign/EpmetCommonServiceOpenFeignClient.java b/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/feign/EpmetCommonServiceOpenFeignClient.java index 73647960c3..1fe124a14f 100644 --- a/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/feign/EpmetCommonServiceOpenFeignClient.java +++ b/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/feign/EpmetCommonServiceOpenFeignClient.java @@ -5,6 +5,7 @@ import com.epmet.commons.tools.utils.Result; import com.epmet.dto.form.*; import com.epmet.dto.result.*; import com.epmet.feign.fallback.EpmetCommonServiceOpenFeignClientFallback; +import com.epmet.feign.fallback.EpmetCommonServiceOpenFeignClientFallbackFactory; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.http.MediaType; import org.springframework.web.bind.annotation.PostMapping; @@ -19,8 +20,8 @@ import java.util.Map; * @author yinzuomei@elink-cn.com * @date 2020/6/4 10:28 */ -@FeignClient(name = ServiceConstant.EPMET_COMMON_SERVICE, fallback = EpmetCommonServiceOpenFeignClientFallback.class) - //@FeignClient(name = ServiceConstant.EPMET_COMMON_SERVICE, fallback = EpmetCommonServiceOpenFeignClientFallback.class, url = "http://192.168.1.132:8103") +@FeignClient(name = ServiceConstant.EPMET_COMMON_SERVICE, fallbackFactory = EpmetCommonServiceOpenFeignClientFallbackFactory.class) + //@FeignClient(name = ServiceConstant.EPMET_COMMON_SERVICE, fallbackFactory = EpmetCommonServiceOpenFeignClientFallbackFactory.class, url = "http://192.168.1.132:8103") public interface EpmetCommonServiceOpenFeignClient { /** * @param formDTO diff --git a/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/feign/fallback/EpmetCommonServiceOpenFeignClientFallback.java b/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/feign/fallback/EpmetCommonServiceOpenFeignClientFallback.java index 4abd2dce39..0483a1d3dc 100644 --- a/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/feign/fallback/EpmetCommonServiceOpenFeignClientFallback.java +++ b/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/feign/fallback/EpmetCommonServiceOpenFeignClientFallback.java @@ -17,7 +17,7 @@ import java.util.Map; * @author yinzuomei@elink-cn.com * @date 2020/6/4 10:32 */ -@Component +//@Component public class EpmetCommonServiceOpenFeignClientFallback implements EpmetCommonServiceOpenFeignClient { @Override public Result> detentionDays(List formDTO) { diff --git a/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/feign/fallback/EpmetCommonServiceOpenFeignClientFallbackFactory.java b/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/feign/fallback/EpmetCommonServiceOpenFeignClientFallbackFactory.java new file mode 100644 index 0000000000..08e4d2977d --- /dev/null +++ b/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/feign/fallback/EpmetCommonServiceOpenFeignClientFallbackFactory.java @@ -0,0 +1,20 @@ +package com.epmet.feign.fallback; + +import com.epmet.commons.tools.exception.ExceptionUtils; +import com.epmet.feign.EpmetCommonServiceOpenFeignClient; +import feign.hystrix.FallbackFactory; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +@Component +@Slf4j +public class EpmetCommonServiceOpenFeignClientFallbackFactory implements FallbackFactory { + + private EpmetCommonServiceOpenFeignClientFallback fallback = new EpmetCommonServiceOpenFeignClientFallback(); + + @Override + public EpmetCommonServiceOpenFeignClient create(Throwable cause) { + log.error(String.format("FeignClient调用发生异常,异常信息:%s", ExceptionUtils.getThrowableErrorStackTrace(cause))); + return fallback; + } +} diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/EpmetCommonServiceApplication.java b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/EpmetCommonServiceApplication.java index 238b8546d4..486ac4bf21 100644 --- a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/EpmetCommonServiceApplication.java +++ b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/EpmetCommonServiceApplication.java @@ -10,6 +10,7 @@ package com.epmet; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.web.servlet.ServletComponentScan; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.cloud.openfeign.EnableFeignClients; @@ -22,6 +23,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients; @SpringBootApplication @EnableDiscoveryClient @EnableFeignClients +@ServletComponentScan public class EpmetCommonServiceApplication { public static void main(String[] args) { diff --git a/epmet-module/epmet-demo/epmet-demo-server/src/main/java/com/epmet/DemoApplication.java b/epmet-module/epmet-demo/epmet-demo-server/src/main/java/com/epmet/DemoApplication.java index ac5ed4ffda..5e83208c30 100644 --- a/epmet-module/epmet-demo/epmet-demo-server/src/main/java/com/epmet/DemoApplication.java +++ b/epmet-module/epmet-demo/epmet-demo-server/src/main/java/com/epmet/DemoApplication.java @@ -10,6 +10,7 @@ package com.epmet; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.web.servlet.ServletComponentScan; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.cloud.openfeign.EnableFeignClients; @@ -22,6 +23,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients; @SpringBootApplication @EnableDiscoveryClient @EnableFeignClients +@ServletComponentScan public class DemoApplication { public static void main(String[] args) { diff --git a/epmet-module/epmet-ext/epmet-ext-server/src/main/java/com/epmet/EpmetExtApplication.java b/epmet-module/epmet-ext/epmet-ext-server/src/main/java/com/epmet/EpmetExtApplication.java index 89508e7873..04b9410c8b 100644 --- a/epmet-module/epmet-ext/epmet-ext-server/src/main/java/com/epmet/EpmetExtApplication.java +++ b/epmet-module/epmet-ext/epmet-ext-server/src/main/java/com/epmet/EpmetExtApplication.java @@ -2,12 +2,14 @@ package com.epmet; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.web.servlet.ServletComponentScan; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.cloud.openfeign.EnableFeignClients; @SpringBootApplication @EnableDiscoveryClient @EnableFeignClients +@ServletComponentScan public class EpmetExtApplication { public static void main(String[] args) { diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/feign/EpmetHeartOpenFeignClient.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/feign/EpmetHeartOpenFeignClient.java index 50efc65a6e..b9f4424ab3 100644 --- a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/feign/EpmetHeartOpenFeignClient.java +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/feign/EpmetHeartOpenFeignClient.java @@ -6,6 +6,7 @@ import com.epmet.dto.ActInfoDTO; import com.epmet.dto.VolunteerInfoDTO; import com.epmet.dto.form.CommonCustomerFormDTO; import com.epmet.feign.fallback.EpmetHeartOpenFeignClientFallback; +import com.epmet.feign.fallback.EpmetHeartOpenFeignClientFallbackFactory; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; @@ -19,7 +20,7 @@ import java.util.List; * @author yinzuomei@elink-cn.com * @date 2020/6/4 13:25 */ -@FeignClient(name = ServiceConstant.EPMET_HEART_SERVER, fallback = EpmetHeartOpenFeignClientFallback.class) +@FeignClient(name = ServiceConstant.EPMET_HEART_SERVER, fallbackFactory = EpmetHeartOpenFeignClientFallbackFactory.class) public interface EpmetHeartOpenFeignClient { /** diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/feign/fallback/EpmetHeartOpenFeignClientFallback.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/feign/fallback/EpmetHeartOpenFeignClientFallback.java index 9e4d671a3b..23759f82c0 100644 --- a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/feign/fallback/EpmetHeartOpenFeignClientFallback.java +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/feign/fallback/EpmetHeartOpenFeignClientFallback.java @@ -17,7 +17,7 @@ import java.util.List; * @author yinzuomei@elink-cn.com * @date 2020/6/4 13:26 */ -@Component +//@Component public class EpmetHeartOpenFeignClientFallback implements EpmetHeartOpenFeignClient { /** diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/feign/fallback/EpmetHeartOpenFeignClientFallbackFactory.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/feign/fallback/EpmetHeartOpenFeignClientFallbackFactory.java new file mode 100644 index 0000000000..d5aa29cf53 --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/feign/fallback/EpmetHeartOpenFeignClientFallbackFactory.java @@ -0,0 +1,20 @@ +package com.epmet.feign.fallback; + +import com.epmet.commons.tools.exception.ExceptionUtils; +import com.epmet.feign.EpmetHeartOpenFeignClient; +import feign.hystrix.FallbackFactory; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +@Component +@Slf4j +public class EpmetHeartOpenFeignClientFallbackFactory implements FallbackFactory { + + private EpmetHeartOpenFeignClientFallback fallback = new EpmetHeartOpenFeignClientFallback(); + + @Override + public EpmetHeartOpenFeignClient create(Throwable cause) { + log.error(String.format("FeignClient调用发生异常,异常信息:%s", ExceptionUtils.getThrowableErrorStackTrace(cause))); + return fallback; + } +} diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/EpmetHeartApplication.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/EpmetHeartApplication.java index 39fd7584e1..c7969a259b 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/EpmetHeartApplication.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/EpmetHeartApplication.java @@ -10,6 +10,7 @@ package com.epmet; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.web.servlet.ServletComponentScan; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.cloud.openfeign.EnableFeignClients; @@ -22,6 +23,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients; @SpringBootApplication @EnableDiscoveryClient @EnableFeignClients +@ServletComponentScan public class EpmetHeartApplication { public static void main(String[] args) { diff --git a/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/JobApplication.java b/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/JobApplication.java index c62390ee4e..5f4ba905ef 100644 --- a/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/JobApplication.java +++ b/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/JobApplication.java @@ -10,6 +10,7 @@ package com.epmet; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.web.servlet.ServletComponentScan; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.cloud.openfeign.EnableFeignClients; @@ -22,6 +23,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients; @SpringBootApplication @EnableDiscoveryClient @EnableFeignClients +@ServletComponentScan public class JobApplication { public static void main(String[] args) { diff --git a/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/feign/EpmetMessageOpenFeignClient.java b/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/feign/EpmetMessageOpenFeignClient.java index ff085c7bc0..f375d75aaf 100644 --- a/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/feign/EpmetMessageOpenFeignClient.java +++ b/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/feign/EpmetMessageOpenFeignClient.java @@ -11,6 +11,7 @@ import com.epmet.dto.form.WxSubscribeMessageFormDTO; import com.epmet.dto.form.WxSubscribeUpdateFormDTO; import com.epmet.dto.result.SendVerificationCodeResultDTO; import com.epmet.feign.fallback.EpmetMessageOpenFeignClientFallback; +import com.epmet.feign.fallback.EpmetMessageOpenFeignClientFallbackFactory; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.http.MediaType; import org.springframework.web.bind.annotation.GetMapping; @@ -27,7 +28,7 @@ import java.util.List; * @date 2020/6/4 13:47 */ //@FeignClient(name = ServiceConstant.EPMET_MESSAGE_SERVER, fallback = EpmetMessageOpenFeignClientFallback.class,url = "http://127.0.0.1:8085") -@FeignClient(name = ServiceConstant.EPMET_MESSAGE_SERVER, fallback = EpmetMessageOpenFeignClientFallback.class) +@FeignClient(name = ServiceConstant.EPMET_MESSAGE_SERVER, fallbackFactory = EpmetMessageOpenFeignClientFallbackFactory.class) public interface EpmetMessageOpenFeignClient { /** * 发送短信 diff --git a/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/feign/fallback/EpmetMessageOpenFeignClientFallback.java b/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/feign/fallback/EpmetMessageOpenFeignClientFallback.java index a77d9152db..069d76c795 100644 --- a/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/feign/fallback/EpmetMessageOpenFeignClientFallback.java +++ b/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/feign/fallback/EpmetMessageOpenFeignClientFallback.java @@ -22,7 +22,7 @@ import java.util.List; * @author yinzuomei@elink-cn.com * @date 2020/6/4 13:48 */ -@Component +//@Component public class EpmetMessageOpenFeignClientFallback implements EpmetMessageOpenFeignClient { @Override diff --git a/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/feign/fallback/EpmetMessageOpenFeignClientFallbackFactory.java b/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/feign/fallback/EpmetMessageOpenFeignClientFallbackFactory.java new file mode 100644 index 0000000000..51e2ec2524 --- /dev/null +++ b/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/feign/fallback/EpmetMessageOpenFeignClientFallbackFactory.java @@ -0,0 +1,20 @@ +package com.epmet.feign.fallback; + +import com.epmet.commons.tools.exception.ExceptionUtils; +import com.epmet.feign.EpmetMessageOpenFeignClient; +import feign.hystrix.FallbackFactory; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +@Component +@Slf4j +public class EpmetMessageOpenFeignClientFallbackFactory implements FallbackFactory { + + private EpmetMessageOpenFeignClientFallback fallback = new EpmetMessageOpenFeignClientFallback(); + + @Override + public EpmetMessageOpenFeignClient create(Throwable cause) { + log.error(String.format("FeignClient调用发生异常,异常信息:%s", ExceptionUtils.getThrowableErrorStackTrace(cause))); + return fallback; + } +} diff --git a/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/MessageApplication.java b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/MessageApplication.java index 98e4151ead..c32da6dd8a 100644 --- a/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/MessageApplication.java +++ b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/MessageApplication.java @@ -10,6 +10,7 @@ package com.epmet; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.web.servlet.ServletComponentScan; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.cloud.openfeign.EnableFeignClients; @@ -22,6 +23,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients; @SpringBootApplication @EnableDiscoveryClient @EnableFeignClients +@ServletComponentScan public class MessageApplication { public static void main(String[] args) { diff --git a/epmet-module/epmet-oss/epmet-oss-client/src/main/java/com/epmet/feign/OssFeignClient.java b/epmet-module/epmet-oss/epmet-oss-client/src/main/java/com/epmet/feign/OssFeignClient.java index 3b1640078d..b5c31ef82f 100644 --- a/epmet-module/epmet-oss/epmet-oss-client/src/main/java/com/epmet/feign/OssFeignClient.java +++ b/epmet-module/epmet-oss/epmet-oss-client/src/main/java/com/epmet/feign/OssFeignClient.java @@ -12,6 +12,7 @@ import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.utils.Result; import com.epmet.dto.result.UploadImgResultDTO; import com.epmet.feign.fallback.OssFeignClientFallback; +import com.epmet.feign.fallback.OssFeignClientFallbackFactory; import feign.codec.Encoder; import feign.form.spring.SpringFormEncoder; import org.springframework.cloud.openfeign.FeignClient; @@ -28,10 +29,10 @@ import org.springframework.web.multipart.MultipartFile; * @author Mark sunlightcs@gmail.c om * @since 1.1.0 */ -@FeignClient(name = ServiceConstant.EPMET_OSS_SERVER, configuration = OssFeignClient.MultipartSupportConfig.class, fallback = - OssFeignClientFallback.class) -//@FeignClient(name = ServiceConstant.EPMET_OSS_SERVER, configuration = OssFeignClient.MultipartSupportConfig.class, fallback = -// OssFeignClientFallback.class) +@FeignClient(name = ServiceConstant.EPMET_OSS_SERVER, configuration = OssFeignClient.MultipartSupportConfig.class, fallbackFactory = + OssFeignClientFallbackFactory.class) +//@FeignClient(name = ServiceConstant.EPMET_OSS_SERVER, configuration = OssFeignClient.MultipartSupportConfig.class, fallbackFactory = +// OssFeignClientFallbackFactory.class) public interface OssFeignClient { /** * 文件上传 diff --git a/epmet-module/epmet-oss/epmet-oss-client/src/main/java/com/epmet/feign/fallback/OssFeignClientFallback.java b/epmet-module/epmet-oss/epmet-oss-client/src/main/java/com/epmet/feign/fallback/OssFeignClientFallback.java index 59529ff293..b60e59cc19 100644 --- a/epmet-module/epmet-oss/epmet-oss-client/src/main/java/com/epmet/feign/fallback/OssFeignClientFallback.java +++ b/epmet-module/epmet-oss/epmet-oss-client/src/main/java/com/epmet/feign/fallback/OssFeignClientFallback.java @@ -22,7 +22,7 @@ import org.springframework.web.multipart.MultipartFile; * @author Mark sunlightcs@gmail.c om * @since 1.1.0 */ -@Component +//@Component public class OssFeignClientFallback implements OssFeignClient { @Override diff --git a/epmet-module/epmet-oss/epmet-oss-client/src/main/java/com/epmet/feign/fallback/OssFeignClientFallbackFactory.java b/epmet-module/epmet-oss/epmet-oss-client/src/main/java/com/epmet/feign/fallback/OssFeignClientFallbackFactory.java new file mode 100644 index 0000000000..63fb593dc8 --- /dev/null +++ b/epmet-module/epmet-oss/epmet-oss-client/src/main/java/com/epmet/feign/fallback/OssFeignClientFallbackFactory.java @@ -0,0 +1,20 @@ +package com.epmet.feign.fallback; + +import com.epmet.commons.tools.exception.ExceptionUtils; +import com.epmet.feign.OssFeignClient; +import feign.hystrix.FallbackFactory; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +@Component +@Slf4j +public class OssFeignClientFallbackFactory implements FallbackFactory { + + private OssFeignClientFallback fallback = new OssFeignClientFallback(); + + @Override + public OssFeignClient create(Throwable cause) { + log.error(String.format("FeignClient调用发生异常,异常信息:%s", ExceptionUtils.getThrowableErrorStackTrace(cause))); + return fallback; + } +} diff --git a/epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/OssApplication.java b/epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/OssApplication.java index 28573fb3ea..3600e58cd3 100644 --- a/epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/OssApplication.java +++ b/epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/OssApplication.java @@ -10,6 +10,7 @@ package com.epmet; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.web.servlet.ServletComponentScan; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.cloud.openfeign.EnableFeignClients; @@ -22,6 +23,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients; @SpringBootApplication @EnableDiscoveryClient @EnableFeignClients +@ServletComponentScan public class OssApplication { public static void main(String[] args) { diff --git a/epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/feign/EpmetPointOpenFeignClient.java b/epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/feign/EpmetPointOpenFeignClient.java index 8093ad3fee..0afba7534e 100644 --- a/epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/feign/EpmetPointOpenFeignClient.java +++ b/epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/feign/EpmetPointOpenFeignClient.java @@ -8,6 +8,7 @@ import com.epmet.dto.form.CommonUserFormDTO; import com.epmet.dto.form.GroupPointFormDTO; import com.epmet.dto.result.ResiPointDetailResultDTO; import com.epmet.feign.fallback.EpmetPointOpenFeignClientFallback; +import com.epmet.feign.fallback.EpmetPointOpenFeignClientFallbackFactory; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; @@ -18,7 +19,7 @@ import org.springframework.web.bind.annotation.RequestBody; * @author wangc * @date 2020/7/9 13:25 */ -@FeignClient(name = ServiceConstant.EPMET_POINT_SERVER, fallback = EpmetPointOpenFeignClientFallback.class) +@FeignClient(name = ServiceConstant.EPMET_POINT_SERVER, fallbackFactory = EpmetPointOpenFeignClientFallbackFactory.class) public interface EpmetPointOpenFeignClient { /** diff --git a/epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/feign/fallback/EpmetPointOpenFeignClientFallback.java b/epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/feign/fallback/EpmetPointOpenFeignClientFallback.java index 04e953edc9..0fc8390a53 100644 --- a/epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/feign/fallback/EpmetPointOpenFeignClientFallback.java +++ b/epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/feign/fallback/EpmetPointOpenFeignClientFallback.java @@ -18,7 +18,7 @@ import org.springframework.web.bind.annotation.RequestParam; * @Auth wangc * @Date 2020-07-10 09:14 */ -@Component +//@Component public class EpmetPointOpenFeignClientFallback implements EpmetPointOpenFeignClient { @Override public Result myPoint(CommonUserFormDTO param) { diff --git a/epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/feign/fallback/EpmetPointOpenFeignClientFallbackFactory.java b/epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/feign/fallback/EpmetPointOpenFeignClientFallbackFactory.java new file mode 100644 index 0000000000..10dce0fcf1 --- /dev/null +++ b/epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/feign/fallback/EpmetPointOpenFeignClientFallbackFactory.java @@ -0,0 +1,20 @@ +package com.epmet.feign.fallback; + +import com.epmet.commons.tools.exception.ExceptionUtils; +import com.epmet.feign.EpmetPointOpenFeignClient; +import feign.hystrix.FallbackFactory; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +@Component +@Slf4j +public class EpmetPointOpenFeignClientFallbackFactory implements FallbackFactory { + + private EpmetPointOpenFeignClientFallback fallback = new EpmetPointOpenFeignClientFallback(); + + @Override + public EpmetPointOpenFeignClient create(Throwable cause) { + log.error(String.format("FeignClient调用发生异常,异常信息:%s", ExceptionUtils.getThrowableErrorStackTrace(cause))); + return fallback; + } +} diff --git a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/EpmetPointApplication.java b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/EpmetPointApplication.java index 4b8eeb035d..e2925628ba 100644 --- a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/EpmetPointApplication.java +++ b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/EpmetPointApplication.java @@ -2,6 +2,7 @@ package com.epmet; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.web.servlet.ServletComponentScan; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.cloud.openfeign.EnableFeignClients; @@ -14,6 +15,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients; @SpringBootApplication @EnableDiscoveryClient @EnableFeignClients +@ServletComponentScan public class EpmetPointApplication { public static void main(String[] args) { SpringApplication.run(EpmetPointApplication.class, args); diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/feign/EpmetThirdOpenFeignClient.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/feign/EpmetThirdOpenFeignClient.java index 125bcb0f48..f71914f828 100644 --- a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/feign/EpmetThirdOpenFeignClient.java +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/feign/EpmetThirdOpenFeignClient.java @@ -6,6 +6,7 @@ import com.epmet.dto.ProjectDTO; import com.epmet.dto.form.*; import com.epmet.dto.result.*; import com.epmet.feign.fallback.EpmetThirdOpenFeignClientFallback; +import com.epmet.feign.fallback.EpmetThirdOpenFeignClientFallbackFactory; import com.epmet.feign.fallback.GovProjectOpenFeignClientFallback; import com.epmet.resi.mine.dto.from.MyPartProjectsFormDTO; import feign.codec.Encoder; @@ -24,9 +25,9 @@ import java.util.List; * @author zhaoqifeng * @date 2021/3/18 14:18 */ -// @FeignClient(name = ServiceConstant.EPMET_THIRD_SERVER, fallback = EpmetThirdOpenFeignClientFallback.class,configuration = +// @FeignClient(name = ServiceConstant.EPMET_THIRD_SERVER, fallbackFactory = EpmetThirdOpenFeignClientFallbackFactory.class,configuration = // EpmetThirdOpenFeignClient.MultipartSupportConfig.class,url = "localhost:8110") -@FeignClient(name = ServiceConstant.EPMET_THIRD_SERVER, fallback = EpmetThirdOpenFeignClientFallback.class, configuration = +@FeignClient(name = ServiceConstant.EPMET_THIRD_SERVER, fallbackFactory = EpmetThirdOpenFeignClientFallbackFactory.class, configuration = EpmetThirdOpenFeignClient.MultipartSupportConfig.class) public interface EpmetThirdOpenFeignClient { /** diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/feign/ThirdOpenFeignClient.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/feign/ThirdOpenFeignClient.java index 4a139daabd..9cfd126d4c 100644 --- a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/feign/ThirdOpenFeignClient.java +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/feign/ThirdOpenFeignClient.java @@ -6,14 +6,15 @@ import com.epmet.dto.form.SaveOrUpdateCustSelPlatformFormDTO; import com.epmet.dto.form.ThirdPlatformFormDTO; import com.epmet.dto.result.ThirdplatformResultDTO; import com.epmet.feign.fallback.ThirdOpenFeignClientFallback; +import com.epmet.feign.fallback.ThirdOpenFeignClientFallbackFactory; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import java.util.List; -@FeignClient(name = ServiceConstant.EPMET_THIRD_SERVER, fallback = ThirdOpenFeignClientFallback.class) -//@FeignClient(name = ServiceConstant.EPMET_THIRD_SERVER, fallback = ThirdOpenFeignClientFallback.class, url = "http://localhost:8110") +@FeignClient(name = ServiceConstant.EPMET_THIRD_SERVER, fallbackFactory = ThirdOpenFeignClientFallbackFactory.class) +//@FeignClient(name = ServiceConstant.EPMET_THIRD_SERVER, fallbackFactory = ThirdOpenFeignClientFallbackFactory.class, url = "http://localhost:8110") public interface ThirdOpenFeignClient { /** diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/feign/fallback/EpmetThirdOpenFeignClientFallback.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/feign/fallback/EpmetThirdOpenFeignClientFallback.java index 89f2245fce..e855799478 100644 --- a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/feign/fallback/EpmetThirdOpenFeignClientFallback.java +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/feign/fallback/EpmetThirdOpenFeignClientFallback.java @@ -18,7 +18,7 @@ import java.util.List; * @author zhaoqifeng * @date 2021/3/18 14:17 */ -@Component +//@Component public class EpmetThirdOpenFeignClientFallback implements EpmetThirdOpenFeignClient { /** diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/feign/fallback/EpmetThirdOpenFeignClientFallbackFactory.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/feign/fallback/EpmetThirdOpenFeignClientFallbackFactory.java new file mode 100644 index 0000000000..a30a43c779 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/feign/fallback/EpmetThirdOpenFeignClientFallbackFactory.java @@ -0,0 +1,18 @@ +package com.epmet.feign.fallback; + +import com.epmet.commons.tools.exception.ExceptionUtils; +import com.epmet.feign.EpmetThirdOpenFeignClient; +import feign.hystrix.FallbackFactory; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +@Component +@Slf4j +public class EpmetThirdOpenFeignClientFallbackFactory implements FallbackFactory { + private EpmetThirdOpenFeignClientFallback fallback = new EpmetThirdOpenFeignClientFallback(); + @Override + public EpmetThirdOpenFeignClient create(Throwable cause) { + log.error(String.format("FeignClient调用发生异常,异常信息:%s", ExceptionUtils.getThrowableErrorStackTrace(cause))); + return fallback; + } +} diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/feign/fallback/ThirdOpenFeignClientFallback.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/feign/fallback/ThirdOpenFeignClientFallback.java index 57a9c808c3..76098de169 100644 --- a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/feign/fallback/ThirdOpenFeignClientFallback.java +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/feign/fallback/ThirdOpenFeignClientFallback.java @@ -11,7 +11,7 @@ import org.springframework.stereotype.Component; import java.util.List; -@Component +//@Component public class ThirdOpenFeignClientFallback implements ThirdOpenFeignClient { @Override public Result saveOrUpdateSelectedPlatformsInfo(SaveOrUpdateCustSelPlatformFormDTO input) { diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/feign/fallback/ThirdOpenFeignClientFallbackFactory.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/feign/fallback/ThirdOpenFeignClientFallbackFactory.java new file mode 100644 index 0000000000..0996aa70c4 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/feign/fallback/ThirdOpenFeignClientFallbackFactory.java @@ -0,0 +1,20 @@ +package com.epmet.feign.fallback; + +import com.epmet.commons.tools.exception.ExceptionUtils; +import com.epmet.feign.ThirdOpenFeignClient; +import feign.hystrix.FallbackFactory; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +@Component +@Slf4j +public class ThirdOpenFeignClientFallbackFactory implements FallbackFactory { + + private ThirdOpenFeignClientFallback fallback = new ThirdOpenFeignClientFallback(); + + @Override + public ThirdOpenFeignClient create(Throwable cause) { + log.error(String.format("FeignClient调用发生异常,异常信息:%s", ExceptionUtils.getThrowableErrorStackTrace(cause))); + return fallback; + } +} diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/EpmetThirdApplication.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/EpmetThirdApplication.java index 2aba843b3f..f2072e4efc 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/EpmetThirdApplication.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/EpmetThirdApplication.java @@ -2,12 +2,14 @@ package com.epmet; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.web.servlet.ServletComponentScan; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.cloud.openfeign.EnableFeignClients; @SpringBootApplication @EnableDiscoveryClient @EnableFeignClients +@ServletComponentScan public class EpmetThirdApplication { public static void main(String[] args) { diff --git a/epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/feign/GovAccessFeignClient.java b/epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/feign/GovAccessFeignClient.java index c142cdef67..5e3a2e0fcb 100644 --- a/epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/feign/GovAccessFeignClient.java +++ b/epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/feign/GovAccessFeignClient.java @@ -4,15 +4,15 @@ import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.utils.Result; import com.epmet.dto.form.InitDefaultOperationsFormDTO; import com.epmet.dto.form.ListOpePermsFormDTO; -import com.epmet.feign.fallback.GovAccessFeignClientFallBack; +import com.epmet.feign.fallback.GovAccessFeignClientFallBackFactory; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import java.util.Set; -//@FeignClient(name = ServiceConstant.GOV_ACCESS_SERVER, fallback = GovAccessFeignClientFallBack.class, url = "http://localhost:8099") -@FeignClient(name = ServiceConstant.GOV_ACCESS_SERVER, fallback = GovAccessFeignClientFallBack.class) +//@FeignClient(name = ServiceConstant.GOV_ACCESS_SERVER, fallbackFactory = GovAccessFeignClientFallBackFactory.class, url = "http://localhost:8099") +@FeignClient(name = ServiceConstant.GOV_ACCESS_SERVER, fallbackFactory = GovAccessFeignClientFallBackFactory.class) public interface GovAccessFeignClient { /** diff --git a/epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/feign/fallback/GovAccessFeignClientFallBack.java b/epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/feign/fallback/GovAccessFeignClientFallBack.java index 30e5d4141c..9f092331ad 100644 --- a/epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/feign/fallback/GovAccessFeignClientFallBack.java +++ b/epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/feign/fallback/GovAccessFeignClientFallBack.java @@ -14,7 +14,7 @@ import java.util.Set; * @Description * @Author sun */ -@Component +//@Component public class GovAccessFeignClientFallBack implements GovAccessFeignClient { diff --git a/epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/feign/fallback/GovAccessFeignClientFallBackFactory.java b/epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/feign/fallback/GovAccessFeignClientFallBackFactory.java new file mode 100644 index 0000000000..6b8b45088e --- /dev/null +++ b/epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/feign/fallback/GovAccessFeignClientFallBackFactory.java @@ -0,0 +1,28 @@ +package com.epmet.feign.fallback; + +import com.epmet.commons.tools.exception.ExceptionUtils; +import com.epmet.feign.GovAccessFeignClient; +import feign.hystrix.FallbackFactory; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +/** + * @Description fallBackFactory,用于抛出异常之后,返回一个Fallback降级处理对象 + * @author wxz + * @date 2021.07.15 09:54:14 +*/ +@Component +@Slf4j +public class GovAccessFeignClientFallBackFactory implements FallbackFactory { + + /** + * 降级处理对象 + */ + private GovAccessFeignClientFallBack fallBack = new GovAccessFeignClientFallBack(); + + @Override + public GovAccessFeignClient create(Throwable cause) { + log.error(String.format("FeignClient调用发生异常,异常信息:%s", ExceptionUtils.getThrowableErrorStackTrace(cause))); + return fallBack; + } +} diff --git a/epmet-module/gov-access/gov-access-server/pom.xml b/epmet-module/gov-access/gov-access-server/pom.xml index d1052635a9..909b706005 100644 --- a/epmet-module/gov-access/gov-access-server/pom.xml +++ b/epmet-module/gov-access/gov-access-server/pom.xml @@ -127,6 +127,10 @@ false + + + https://oapi.dingtalk.com/robot/send?access_token=e894e5690f9d6a527722974c71548ff6c0fe29bd956589a09e21b16442a35ed4 + SECfcc020bdc83bb17a2c00f39977b1fbc409ef4188c7beaea11c5caa90eeaf87fd @@ -160,6 +164,10 @@ false + + + https://oapi.dingtalk.com/robot/send?access_token=e894e5690f9d6a527722974c71548ff6c0fe29bd956589a09e21b16442a35ed4 + SECfcc020bdc83bb17a2c00f39977b1fbc409ef4188c7beaea11c5caa90eeaf87fd @@ -193,6 +201,10 @@ true + + + https://oapi.dingtalk.com/robot/send?access_token=e894e5690f9d6a527722974c71548ff6c0fe29bd956589a09e21b16442a35ed4 + SECfcc020bdc83bb17a2c00f39977b1fbc409ef4188c7beaea11c5caa90eeaf87fd @@ -223,6 +235,10 @@ true + + + https://oapi.dingtalk.com/robot/send?access_token=a5f66c3374b1642fe2142dbf56d5997e280172d4e8f2b546c9423a68c82ece6c + SEC95f4f40b533ad379ea6a6d1af6dd37029383cfe1b7cd96dfac2678be2c1c3ed1 diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/GovAccessApplication.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/GovAccessApplication.java index 469de9dc52..6068061b0b 100644 --- a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/GovAccessApplication.java +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/GovAccessApplication.java @@ -2,6 +2,7 @@ package com.epmet; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.web.servlet.ServletComponentScan; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.cloud.openfeign.EnableFeignClients; @@ -12,6 +13,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients; @SpringBootApplication @EnableDiscoveryClient @EnableFeignClients +@ServletComponentScan //@EnableConfigurationProperties(value = {DatabaseProperties.class}) public class GovAccessApplication { public static void main(String[] args) { diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/controller/TestController.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/controller/TestController.java index b8ab2dbda6..b18beb3aab 100644 --- a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/controller/TestController.java +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/controller/TestController.java @@ -1,12 +1,11 @@ package com.epmet.controller; import com.epmet.commons.tools.annotation.ExternalRequestAuth; +import com.epmet.commons.tools.exception.RenException; import com.epmet.service.TestService; +import lombok.Data; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; @RestController @RequestMapping("test") @@ -16,10 +15,17 @@ public class TestController { private TestService testService; @ExternalRequestAuth - @GetMapping("test") - public void test() { - System.out.println("TestController -> test()"); + @PostMapping("test") + public void test(@RequestBody Input input) { + if (true) { + throw new RenException("测试报错"); + } testService.test(); } + @Data + public static class Input { + private String name; + } + } diff --git a/epmet-module/gov-access/gov-access-server/src/main/resources/bootstrap.yml b/epmet-module/gov-access/gov-access-server/src/main/resources/bootstrap.yml index d2038e569e..978f85db31 100644 --- a/epmet-module/gov-access/gov-access-server/src/main/resources/bootstrap.yml +++ b/epmet-module/gov-access/gov-access-server/src/main/resources/bootstrap.yml @@ -124,3 +124,8 @@ pagehelper: logging: level: com.epmet: debug + +dingTalk: + robot: + webHook: @dingTalk.robot.webHook@ + secret: @dingTalk.robot.secret@ \ No newline at end of file diff --git a/epmet-module/gov-access/gov-access-server/src/main/resources/logback-spring.xml b/epmet-module/gov-access/gov-access-server/src/main/resources/logback-spring.xml index 45b1ddc4e0..c53f4711fe 100644 --- a/epmet-module/gov-access/gov-access-server/src/main/resources/logback-spring.xml +++ b/epmet-module/gov-access/gov-access-server/src/main/resources/logback-spring.xml @@ -6,6 +6,9 @@ + + + ${appname} @@ -125,16 +128,25 @@ 15 - - + + ERROR ACCEPT DENY + ${webHook} + ${secret} + ${appname} + + - + diff --git a/epmet-module/gov-grid/gov-grid-server/src/main/java/com/epmet/GovGridApplication.java b/epmet-module/gov-grid/gov-grid-server/src/main/java/com/epmet/GovGridApplication.java index ac047e4a68..875c62f1eb 100644 --- a/epmet-module/gov-grid/gov-grid-server/src/main/java/com/epmet/GovGridApplication.java +++ b/epmet-module/gov-grid/gov-grid-server/src/main/java/com/epmet/GovGridApplication.java @@ -2,6 +2,7 @@ package com.epmet; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.web.servlet.ServletComponentScan; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.cloud.openfeign.EnableFeignClients; @@ -14,6 +15,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients; @SpringBootApplication @EnableDiscoveryClient @EnableFeignClients +@ServletComponentScan public class GovGridApplication { public static void main(String[] args) { diff --git a/epmet-module/gov-issue/gov-issue-client/src/main/java/com/epmet/feign/GovIssueOpenFeignClient.java b/epmet-module/gov-issue/gov-issue-client/src/main/java/com/epmet/feign/GovIssueOpenFeignClient.java index a5179ea765..20e21a4277 100644 --- a/epmet-module/gov-issue/gov-issue-client/src/main/java/com/epmet/feign/GovIssueOpenFeignClient.java +++ b/epmet-module/gov-issue/gov-issue-client/src/main/java/com/epmet/feign/GovIssueOpenFeignClient.java @@ -6,6 +6,7 @@ import com.epmet.dto.*; import com.epmet.dto.form.*; import com.epmet.dto.result.*; import com.epmet.feign.fallback.GovIssueOpenFeignClientFallBack; +import com.epmet.feign.fallback.GovIssueOpenFeignClientFallBackFactory; import com.epmet.project.dto.CustomerCategoryDTO; import com.epmet.project.dto.result.ProjectCategoryDictResultDTO; import com.epmet.resi.group.dto.group.form.AllIssueFormDTO; @@ -34,8 +35,8 @@ import java.util.Map; * @author yinzuomei@elink-cn.com * @date 2020/6/4 13:37 */ -@FeignClient(name = ServiceConstant.GOV_ISSUE_SERVER, fallback = GovIssueOpenFeignClientFallBack.class) -//@FeignClient(name = ServiceConstant.GOV_ISSUE_SERVER, fallback = GovIssueOpenFeignClientFallBack.class,url = "localhost:8101") +@FeignClient(name = ServiceConstant.GOV_ISSUE_SERVER, fallbackFactory = GovIssueOpenFeignClientFallBackFactory.class) +//@FeignClient(name = ServiceConstant.GOV_ISSUE_SERVER, fallbackFactory = GovIssueOpenFeignClientFallBackFactory.class,url = "localhost:8101") public interface GovIssueOpenFeignClient { /** diff --git a/epmet-module/gov-issue/gov-issue-client/src/main/java/com/epmet/feign/fallback/GovIssueOpenFeignClientFallBack.java b/epmet-module/gov-issue/gov-issue-client/src/main/java/com/epmet/feign/fallback/GovIssueOpenFeignClientFallBack.java index 6808afaee5..8bb48b0075 100644 --- a/epmet-module/gov-issue/gov-issue-client/src/main/java/com/epmet/feign/fallback/GovIssueOpenFeignClientFallBack.java +++ b/epmet-module/gov-issue/gov-issue-client/src/main/java/com/epmet/feign/fallback/GovIssueOpenFeignClientFallBack.java @@ -30,7 +30,7 @@ import java.util.Map; * @author yinzuomei@elink-cn.com * @date 2020/6/4 13:43 */ -@Component +//@Component public class GovIssueOpenFeignClientFallBack implements GovIssueOpenFeignClient { @Override public Result applicationDetail(ApplicationDetailFormDTO applicationDetailFormDTO) { diff --git a/epmet-module/gov-issue/gov-issue-client/src/main/java/com/epmet/feign/fallback/GovIssueOpenFeignClientFallBackFactory.java b/epmet-module/gov-issue/gov-issue-client/src/main/java/com/epmet/feign/fallback/GovIssueOpenFeignClientFallBackFactory.java new file mode 100644 index 0000000000..02df667c68 --- /dev/null +++ b/epmet-module/gov-issue/gov-issue-client/src/main/java/com/epmet/feign/fallback/GovIssueOpenFeignClientFallBackFactory.java @@ -0,0 +1,20 @@ +package com.epmet.feign.fallback; + +import com.epmet.commons.tools.exception.ExceptionUtils; +import com.epmet.feign.GovIssueOpenFeignClient; +import feign.hystrix.FallbackFactory; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +@Component +@Slf4j +public class GovIssueOpenFeignClientFallBackFactory implements FallbackFactory { + + private GovIssueOpenFeignClientFallBack fallback = new GovIssueOpenFeignClientFallBack(); + + @Override + public GovIssueOpenFeignClient create(Throwable cause) { + log.error(String.format("FeignClient调用发生异常,异常信息:%s", ExceptionUtils.getThrowableErrorStackTrace(cause))); + return fallback; + } +} diff --git a/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/GovIssueApplication.java b/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/GovIssueApplication.java index 36764f5de8..ef94eca399 100644 --- a/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/GovIssueApplication.java +++ b/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/GovIssueApplication.java @@ -2,6 +2,7 @@ package com.epmet; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.web.servlet.ServletComponentScan; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.cloud.openfeign.EnableFeignClients; @@ -13,6 +14,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients; @SpringBootApplication @EnableDiscoveryClient @EnableFeignClients +@ServletComponentScan public class GovIssueApplication { public static void main(String[] args) { SpringApplication.run(GovIssueApplication.class, args); diff --git a/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/GovMineApplication.java b/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/GovMineApplication.java index f804c3926e..5dad0a50c8 100644 --- a/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/GovMineApplication.java +++ b/epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/GovMineApplication.java @@ -2,12 +2,14 @@ package com.epmet; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.web.servlet.ServletComponentScan; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.cloud.openfeign.EnableFeignClients; @SpringBootApplication @EnableDiscoveryClient @EnableFeignClients +@ServletComponentScan public class GovMineApplication { public static void main(String[] args) { diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/GovOrgOpenFeignClient.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/GovOrgOpenFeignClient.java index c11cdb7874..bf6df86b7b 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/GovOrgOpenFeignClient.java +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/GovOrgOpenFeignClient.java @@ -8,6 +8,7 @@ import com.epmet.dto.CustomerPartyBranchDTO; import com.epmet.dto.form.*; import com.epmet.dto.result.*; import com.epmet.feign.fallback.GovOrgOpenFeignClientFallback; +import com.epmet.feign.fallback.GovOrgOpenFeignClientFallbackFactory; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.http.MediaType; import org.springframework.web.bind.annotation.*; @@ -20,8 +21,8 @@ import java.util.List; * @author yinzuomei@elink-cn.com * @date 2020/6/4 13:37 */ -//@FeignClient(name = ServiceConstant.GOV_ORG_SERVER, fallback = GovOrgOpenFeignClientFallback.class, url = "localhost:8092") -@FeignClient(name = ServiceConstant.GOV_ORG_SERVER, fallback = GovOrgOpenFeignClientFallback.class) +//@FeignClient(name = ServiceConstant.GOV_ORG_SERVER, fallbackFactory = GovOrgOpenFeignClientFallbackFactory.class, url = "localhost:8092") +@FeignClient(name = ServiceConstant.GOV_ORG_SERVER, fallbackFactory = GovOrgOpenFeignClientFallbackFactory.class) public interface GovOrgOpenFeignClient { /** diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/fallback/GovOrgOpenFeignClientFallback.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/fallback/GovOrgOpenFeignClientFallback.java index 8110e53936..c384f302aa 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/fallback/GovOrgOpenFeignClientFallback.java +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/fallback/GovOrgOpenFeignClientFallback.java @@ -19,7 +19,7 @@ import java.util.List; * @author yinzuomei@elink-cn.com * @date 2020/6/4 13:37 */ -@Component +//@Component public class GovOrgOpenFeignClientFallback implements GovOrgOpenFeignClient { @Override public Result getAgencyById(String agencyId) { diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/fallback/GovOrgOpenFeignClientFallbackFactory.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/fallback/GovOrgOpenFeignClientFallbackFactory.java new file mode 100644 index 0000000000..6be2be24fe --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/fallback/GovOrgOpenFeignClientFallbackFactory.java @@ -0,0 +1,20 @@ +package com.epmet.feign.fallback; + +import com.epmet.commons.tools.exception.ExceptionUtils; +import com.epmet.feign.GovOrgOpenFeignClient; +import feign.hystrix.FallbackFactory; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +@Component +@Slf4j +public class GovOrgOpenFeignClientFallbackFactory implements FallbackFactory { + + private GovOrgOpenFeignClientFallback fallback = new GovOrgOpenFeignClientFallback(); + + @Override + public GovOrgOpenFeignClient create(Throwable cause) { + log.error(String.format("FeignClient调用发生异常,异常信息:%s", ExceptionUtils.getThrowableErrorStackTrace(cause))); + return fallback; + } +} diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/GovOrgApplication.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/GovOrgApplication.java index d4cafe7020..ff43e6542c 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/GovOrgApplication.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/GovOrgApplication.java @@ -10,6 +10,7 @@ package com.epmet; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.web.servlet.ServletComponentScan; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.cloud.openfeign.EnableFeignClients; @@ -22,6 +23,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients; @SpringBootApplication @EnableDiscoveryClient @EnableFeignClients +@ServletComponentScan public class GovOrgApplication { public static void main(String[] args) { diff --git a/epmet-module/gov-project/gov-project-client/src/main/java/com/epmet/feign/GovProjectOpenFeignClient.java b/epmet-module/gov-project/gov-project-client/src/main/java/com/epmet/feign/GovProjectOpenFeignClient.java index 7bd2b95f31..6d5c1d01ac 100644 --- a/epmet-module/gov-project/gov-project-client/src/main/java/com/epmet/feign/GovProjectOpenFeignClient.java +++ b/epmet-module/gov-project/gov-project-client/src/main/java/com/epmet/feign/GovProjectOpenFeignClient.java @@ -7,6 +7,7 @@ import com.epmet.dto.ProjectDTO; import com.epmet.dto.form.*; import com.epmet.dto.result.*; import com.epmet.feign.fallback.GovProjectOpenFeignClientFallback; +import com.epmet.feign.fallback.GovProjectOpenFeignClientFallbackFactory; import com.epmet.resi.mine.dto.from.MyPartProjectsFormDTO; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.GetMapping; @@ -22,8 +23,8 @@ import java.util.List; * @author yinzuomei@elink-cn.com * @date 2020/6/4 13:32 */ -// @FeignClient(name = ServiceConstant.GOV_PROJECT_SERVER, fallback = GovProjectOpenFeignClientFallback.class,url = "localhost:8102") -@FeignClient(name = ServiceConstant.GOV_PROJECT_SERVER, fallback = GovProjectOpenFeignClientFallback.class) +// @FeignClient(name = ServiceConstant.GOV_PROJECT_SERVER, fallbackFactory = GovProjectOpenFeignClientFallbackFactory.class,url = "localhost:8102") +@FeignClient(name = ServiceConstant.GOV_PROJECT_SERVER, fallbackFactory = GovProjectOpenFeignClientFallbackFactory.class) public interface GovProjectOpenFeignClient { /** * 待处理项目列表 diff --git a/epmet-module/gov-project/gov-project-client/src/main/java/com/epmet/feign/fallback/GovProjectOpenFeignClientFallback.java b/epmet-module/gov-project/gov-project-client/src/main/java/com/epmet/feign/fallback/GovProjectOpenFeignClientFallback.java index cb2dbf1abd..d6a4661b96 100644 --- a/epmet-module/gov-project/gov-project-client/src/main/java/com/epmet/feign/fallback/GovProjectOpenFeignClientFallback.java +++ b/epmet-module/gov-project/gov-project-client/src/main/java/com/epmet/feign/fallback/GovProjectOpenFeignClientFallback.java @@ -19,7 +19,7 @@ import java.util.List; * @author yinzuomei@elink-cn.com * @date 2020/6/4 13:33 */ -@Component +//@Component public class GovProjectOpenFeignClientFallback implements GovProjectOpenFeignClient { @Override public Result> getPendProjectList(ProjectListFromDTO fromDTO) { diff --git a/epmet-module/gov-project/gov-project-client/src/main/java/com/epmet/feign/fallback/GovProjectOpenFeignClientFallbackFactory.java b/epmet-module/gov-project/gov-project-client/src/main/java/com/epmet/feign/fallback/GovProjectOpenFeignClientFallbackFactory.java new file mode 100644 index 0000000000..ac6908852a --- /dev/null +++ b/epmet-module/gov-project/gov-project-client/src/main/java/com/epmet/feign/fallback/GovProjectOpenFeignClientFallbackFactory.java @@ -0,0 +1,20 @@ +package com.epmet.feign.fallback; + +import com.epmet.commons.tools.exception.ExceptionUtils; +import com.epmet.feign.GovProjectOpenFeignClient; +import feign.hystrix.FallbackFactory; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +@Component +@Slf4j +public class GovProjectOpenFeignClientFallbackFactory implements FallbackFactory { + + private GovProjectOpenFeignClientFallback fallback = new GovProjectOpenFeignClientFallback(); + + @Override + public GovProjectOpenFeignClient create(Throwable cause) { + log.error(String.format("FeignClient调用发生异常,异常信息:%s", ExceptionUtils.getThrowableErrorStackTrace(cause))); + return fallback; + } +} diff --git a/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/GovProjectApplication.java b/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/GovProjectApplication.java index ad4410f584..37c767c4b3 100644 --- a/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/GovProjectApplication.java +++ b/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/GovProjectApplication.java @@ -2,6 +2,7 @@ package com.epmet; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.web.servlet.ServletComponentScan; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.cloud.openfeign.EnableFeignClients; @@ -13,6 +14,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients; @SpringBootApplication @EnableDiscoveryClient @EnableFeignClients +@ServletComponentScan public class GovProjectApplication { public static void main(String[] args) { SpringApplication.run(GovProjectApplication.class, args); diff --git a/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/feign/GovVoiceOpenFeignClient.java b/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/feign/GovVoiceOpenFeignClient.java index 888d2f16eb..bfad56b2f5 100644 --- a/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/feign/GovVoiceOpenFeignClient.java +++ b/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/feign/GovVoiceOpenFeignClient.java @@ -6,6 +6,7 @@ import com.epmet.commons.tools.utils.Result; import com.epmet.dto.form.*; import com.epmet.dto.result.*; import com.epmet.feign.fallback.GovVoiceOpenFeignClientFallback; +import com.epmet.feign.fallback.GovVoiceOpenFeignClientFallbackFactory; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; @@ -18,7 +19,7 @@ import java.util.List; * @author yinzuomei@elink-cn.com * @date 2020/6/4 16:01 */ -@FeignClient(name = ServiceConstant.GOV_VOICE_SERVER, fallback = GovVoiceOpenFeignClientFallback.class) +@FeignClient(name = ServiceConstant.GOV_VOICE_SERVER, fallbackFactory = GovVoiceOpenFeignClientFallbackFactory.class) public interface GovVoiceOpenFeignClient { /** diff --git a/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/feign/fallback/GovVoiceOpenFeignClientFallback.java b/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/feign/fallback/GovVoiceOpenFeignClientFallback.java index c2d0d3c4cb..86af110762 100644 --- a/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/feign/fallback/GovVoiceOpenFeignClientFallback.java +++ b/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/feign/fallback/GovVoiceOpenFeignClientFallback.java @@ -16,7 +16,7 @@ import java.util.List; * @author yinzuomei@elink-cn.com * @date 2020/6/4 16:01 */ -@Component +//@Component public class GovVoiceOpenFeignClientFallback implements GovVoiceOpenFeignClient { @Override public Result> resiTagList(ResiTagListFormDTO formDto) { diff --git a/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/feign/fallback/GovVoiceOpenFeignClientFallbackFactory.java b/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/feign/fallback/GovVoiceOpenFeignClientFallbackFactory.java new file mode 100644 index 0000000000..06552997e0 --- /dev/null +++ b/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/feign/fallback/GovVoiceOpenFeignClientFallbackFactory.java @@ -0,0 +1,20 @@ +package com.epmet.feign.fallback; + +import com.epmet.commons.tools.exception.ExceptionUtils; +import com.epmet.feign.GovVoiceOpenFeignClient; +import feign.hystrix.FallbackFactory; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +@Component +@Slf4j +public class GovVoiceOpenFeignClientFallbackFactory implements FallbackFactory { + + private GovVoiceOpenFeignClientFallback fallback = new GovVoiceOpenFeignClientFallback(); + + @Override + public GovVoiceOpenFeignClient create(Throwable cause) { + log.error(String.format("FeignClient调用发生异常,异常信息:%s", ExceptionUtils.getThrowableErrorStackTrace(cause))); + return fallback; + } +} diff --git a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/GovVoiceApplication.java b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/GovVoiceApplication.java index db1073c8e8..b5d7919388 100644 --- a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/GovVoiceApplication.java +++ b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/GovVoiceApplication.java @@ -2,6 +2,7 @@ package com.epmet; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.web.servlet.ServletComponentScan; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.cloud.openfeign.EnableFeignClients; import org.springframework.scheduling.annotation.EnableAsync; @@ -15,6 +16,7 @@ import org.springframework.scheduling.annotation.EnableAsync; @EnableDiscoveryClient @EnableFeignClients @EnableAsync +@ServletComponentScan public class GovVoiceApplication { public static void main(String[] args) { SpringApplication.run(GovVoiceApplication.class, args); diff --git a/epmet-module/oper-access/oper-access-client/src/main/java/com/epmet/feign/OperAccessOpenFeignClient.java b/epmet-module/oper-access/oper-access-client/src/main/java/com/epmet/feign/OperAccessOpenFeignClient.java index cba3dfa021..c89b3f39c9 100644 --- a/epmet-module/oper-access/oper-access-client/src/main/java/com/epmet/feign/OperAccessOpenFeignClient.java +++ b/epmet-module/oper-access/oper-access-client/src/main/java/com/epmet/feign/OperAccessOpenFeignClient.java @@ -1,5 +1,6 @@ package com.epmet.feign; +import com.epmet.feign.fallback.OperAccessOpenFeignClientFallbackFactory; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.GetMapping; @@ -13,7 +14,7 @@ import com.epmet.feign.fallback.OperAccessOpenFeignClientFallback; * @Date 2020/5/21 15:17 本服务对外开放的API,其他服务通过引用此client调用该服务 */ // , url = "http://localhost:8093" -@FeignClient(name = ServiceConstant.OPER_ACCESS_SERVER, fallback = OperAccessOpenFeignClientFallback.class) +@FeignClient(name = ServiceConstant.OPER_ACCESS_SERVER, fallbackFactory = OperAccessOpenFeignClientFallbackFactory.class) public interface OperAccessOpenFeignClient { /** * @param diff --git a/epmet-module/oper-access/oper-access-client/src/main/java/com/epmet/feign/fallback/OperAccessOpenFeignClientFallback.java b/epmet-module/oper-access/oper-access-client/src/main/java/com/epmet/feign/fallback/OperAccessOpenFeignClientFallback.java index 32693f4ed8..b062f8f372 100644 --- a/epmet-module/oper-access/oper-access-client/src/main/java/com/epmet/feign/fallback/OperAccessOpenFeignClientFallback.java +++ b/epmet-module/oper-access/oper-access-client/src/main/java/com/epmet/feign/fallback/OperAccessOpenFeignClientFallback.java @@ -11,7 +11,7 @@ import org.springframework.stereotype.Component; * @Author yinzuomei * @Date 2020/5/21 15:47 */ -@Component +//@Component public class OperAccessOpenFeignClientFallback implements OperAccessOpenFeignClient { @Override public Result clearOperUserAccess() { diff --git a/epmet-module/oper-access/oper-access-client/src/main/java/com/epmet/feign/fallback/OperAccessOpenFeignClientFallbackFactory.java b/epmet-module/oper-access/oper-access-client/src/main/java/com/epmet/feign/fallback/OperAccessOpenFeignClientFallbackFactory.java new file mode 100644 index 0000000000..cb07e9b4cd --- /dev/null +++ b/epmet-module/oper-access/oper-access-client/src/main/java/com/epmet/feign/fallback/OperAccessOpenFeignClientFallbackFactory.java @@ -0,0 +1,19 @@ +package com.epmet.feign.fallback; + +import com.epmet.commons.tools.exception.ExceptionUtils; +import com.epmet.feign.OperAccessOpenFeignClient; +import feign.hystrix.FallbackFactory; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +@Component +@Slf4j +public class OperAccessOpenFeignClientFallbackFactory implements FallbackFactory { + private OperAccessOpenFeignClientFallback fallback = new OperAccessOpenFeignClientFallback(); + + @Override + public OperAccessOpenFeignClient create(Throwable cause) { + log.error(String.format("FeignClient调用发生异常,异常信息:%s", ExceptionUtils.getThrowableErrorStackTrace(cause))); + return fallback; + } +} diff --git a/epmet-module/oper-access/oper-access-server/src/main/java/com/epmet/OperAccessApplication.java b/epmet-module/oper-access/oper-access-server/src/main/java/com/epmet/OperAccessApplication.java index 6656d79909..4f8a0d8279 100644 --- a/epmet-module/oper-access/oper-access-server/src/main/java/com/epmet/OperAccessApplication.java +++ b/epmet-module/oper-access/oper-access-server/src/main/java/com/epmet/OperAccessApplication.java @@ -2,6 +2,7 @@ package com.epmet; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.web.servlet.ServletComponentScan; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.cloud.openfeign.EnableFeignClients; @@ -14,6 +15,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients; @SpringBootApplication @EnableDiscoveryClient @EnableFeignClients +@ServletComponentScan public class OperAccessApplication { public static void main(String[] args) { SpringApplication.run(OperAccessApplication.class, args); diff --git a/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/OperCrmOpenFeignClient.java b/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/OperCrmOpenFeignClient.java index 04508ac6df..500e09eaca 100644 --- a/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/OperCrmOpenFeignClient.java +++ b/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/OperCrmOpenFeignClient.java @@ -10,6 +10,7 @@ import com.epmet.dto.result.CustomerRelationInfoResultDTO; import com.epmet.dto.result.GridCountResultDTO; import com.epmet.dto.result.ThirdplatApiserviceResultDTO; import com.epmet.feign.fallback.OperCrmOpenFeignClientFallback; +import com.epmet.feign.fallback.OperCrmOpenFeignClientFallbackFactory; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; @@ -24,8 +25,8 @@ import java.util.List; * @author yinzuomei@elink-cn.com * @date 2020/6/4 13:25 */ -@FeignClient(name = ServiceConstant.OPER_CRM_SERVER, fallback = OperCrmOpenFeignClientFallback.class) -// @FeignClient(name = ServiceConstant.OPER_CRM_SERVER, fallback = OperCrmOpenFeignClientFallback.class, url = "localhost:8090") +@FeignClient(name = ServiceConstant.OPER_CRM_SERVER, fallbackFactory = OperCrmOpenFeignClientFallbackFactory.class) +// @FeignClient(name = ServiceConstant.OPER_CRM_SERVER, fallbackFactory = OperCrmOpenFeignClientFallbackFactory.class, url = "localhost:8090") public interface OperCrmOpenFeignClient { /** * 获取客户信息 diff --git a/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/fallback/OperCrmOpenFeignClientFallback.java b/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/fallback/OperCrmOpenFeignClientFallback.java index b718517d4b..c25fbcfc25 100644 --- a/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/fallback/OperCrmOpenFeignClientFallback.java +++ b/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/fallback/OperCrmOpenFeignClientFallback.java @@ -21,7 +21,7 @@ import java.util.List; * @author yinzuomei@elink-cn.com * @date 2020/6/4 13:26 */ -@Component +//@Component public class OperCrmOpenFeignClientFallback implements OperCrmOpenFeignClient { @Override public Result getCustomerInfo(CustomerDTO dto) { diff --git a/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/fallback/OperCrmOpenFeignClientFallbackFactory.java b/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/fallback/OperCrmOpenFeignClientFallbackFactory.java new file mode 100644 index 0000000000..5a1f2e0ded --- /dev/null +++ b/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/fallback/OperCrmOpenFeignClientFallbackFactory.java @@ -0,0 +1,20 @@ +package com.epmet.feign.fallback; + +import com.epmet.commons.tools.exception.ExceptionUtils; +import com.epmet.feign.OperCrmOpenFeignClient; +import feign.hystrix.FallbackFactory; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +@Component +@Slf4j +public class OperCrmOpenFeignClientFallbackFactory implements FallbackFactory { + + private OperCrmOpenFeignClientFallback fallback = new OperCrmOpenFeignClientFallback(); + + @Override + public OperCrmOpenFeignClient create(Throwable cause) { + log.error(String.format("FeignClient调用发生异常,异常信息:%s", ExceptionUtils.getThrowableErrorStackTrace(cause))); + return fallback; + } +} diff --git a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/OperCrmApplication.java b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/OperCrmApplication.java index e0217c141d..37d5036585 100644 --- a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/OperCrmApplication.java +++ b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/OperCrmApplication.java @@ -10,6 +10,7 @@ package com.epmet; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.web.servlet.ServletComponentScan; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.cloud.openfeign.EnableFeignClients; @@ -22,6 +23,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients; @SpringBootApplication @EnableDiscoveryClient @EnableFeignClients +@ServletComponentScan public class OperCrmApplication { public static void main(String[] args) { diff --git a/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/feign/OperCustomizeOpenFeignClient.java b/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/feign/OperCustomizeOpenFeignClient.java index 62c90892f6..7674dbc437 100644 --- a/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/feign/OperCustomizeOpenFeignClient.java +++ b/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/feign/OperCustomizeOpenFeignClient.java @@ -3,6 +3,7 @@ package com.epmet.feign; import com.epmet.commons.tools.utils.Result; import com.epmet.dto.CustomerFootBarDTO; import com.epmet.dto.form.CustomerFootBarFormDTO; +import com.epmet.feign.fallback.OperCustomizeOpenFeignClientFallbackFactory; import org.springframework.cloud.openfeign.FeignClient; import com.epmet.commons.tools.constant.ServiceConstant; @@ -28,7 +29,7 @@ import java.util.List; * @author yinzuomei@elink-cn.com * @date 2020/6/4 13:16 */ -@FeignClient(name = ServiceConstant.OPER_CUSTOMIZE_SERVER, fallback = OperCustomizeOpenFeignClientFallback.class) +@FeignClient(name = ServiceConstant.OPER_CUSTOMIZE_SERVER, fallbackFactory = OperCustomizeOpenFeignClientFallbackFactory.class) public interface OperCustomizeOpenFeignClient { @PostMapping(value = "/oper/customize/customerfootbar/customerfootbars", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE) diff --git a/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/feign/fallback/OperCustomizeOpenFeignClientFallback.java b/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/feign/fallback/OperCustomizeOpenFeignClientFallback.java index 3958e89268..3e4664048d 100644 --- a/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/feign/fallback/OperCustomizeOpenFeignClientFallback.java +++ b/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/feign/fallback/OperCustomizeOpenFeignClientFallback.java @@ -21,7 +21,7 @@ import java.util.List; * @author yinzuomei@elink-cn.com * @date 2020/6/4 13:23 */ -@Component +//@Component public class OperCustomizeOpenFeignClientFallback implements OperCustomizeOpenFeignClient { @Override public Result> getCustomerfootbars(CustomerFootBarFormDTO formDTO) { diff --git a/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/feign/fallback/OperCustomizeOpenFeignClientFallbackFactory.java b/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/feign/fallback/OperCustomizeOpenFeignClientFallbackFactory.java new file mode 100644 index 0000000000..935c287323 --- /dev/null +++ b/epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/feign/fallback/OperCustomizeOpenFeignClientFallbackFactory.java @@ -0,0 +1,20 @@ +package com.epmet.feign.fallback; + +import com.epmet.commons.tools.exception.ExceptionUtils; +import com.epmet.feign.OperCustomizeOpenFeignClient; +import feign.hystrix.FallbackFactory; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +@Component +@Slf4j +public class OperCustomizeOpenFeignClientFallbackFactory implements FallbackFactory { + + private OperCustomizeOpenFeignClientFallback fallback = new OperCustomizeOpenFeignClientFallback(); + + @Override + public OperCustomizeOpenFeignClient create(Throwable cause) { + log.error(String.format("FeignClient调用发生异常,异常信息:%s", ExceptionUtils.getThrowableErrorStackTrace(cause))); + return fallback; + } +} diff --git a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/OperCustomizeApplication.java b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/OperCustomizeApplication.java index ebd25952d0..d69216a53d 100644 --- a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/OperCustomizeApplication.java +++ b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/OperCustomizeApplication.java @@ -10,6 +10,7 @@ package com.epmet; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.web.servlet.ServletComponentScan; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.cloud.openfeign.EnableFeignClients; @@ -22,6 +23,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients; @SpringBootApplication @EnableDiscoveryClient @EnableFeignClients +@ServletComponentScan public class OperCustomizeApplication { public static void main(String[] args) { diff --git a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/feign/ResiGroupOpenFeignClient.java b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/feign/ResiGroupOpenFeignClient.java index 3401323760..16e1d8b0c8 100644 --- a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/feign/ResiGroupOpenFeignClient.java +++ b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/feign/ResiGroupOpenFeignClient.java @@ -12,6 +12,7 @@ import com.epmet.resi.group.dto.topic.form.*; import com.epmet.resi.group.dto.topic.result.*; import com.epmet.resi.group.dto.topic.result.TopicInfoResultDTO; import com.epmet.resi.group.feign.fallback.ResiGroupOpenFeignClientFallback; +import com.epmet.resi.group.feign.fallback.ResiGroupOpenFeignClientFallbackFactory; import com.epmet.resi.mine.dto.from.MyPartProjectsFormDTO; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.http.MediaType; @@ -26,8 +27,8 @@ import java.util.List; * @author yinzuomei@elink-cn.com * @date 2020/6/4 13:16 */ -@FeignClient(name = ServiceConstant.RESI_GROUP_SERVER, fallback = ResiGroupOpenFeignClientFallback.class) - //@FeignClient(name = ServiceConstant.RESI_GROUP_SERVER, fallback = ResiGroupOpenFeignClientFallback.class,url = "localhost:8095") +@FeignClient(name = ServiceConstant.RESI_GROUP_SERVER, fallbackFactory = ResiGroupOpenFeignClientFallbackFactory.class) + //@FeignClient(name = ServiceConstant.RESI_GROUP_SERVER, fallbackFactory = ResiGroupOpenFeignClientFallbackFactory.class,url = "localhost:8095") public interface ResiGroupOpenFeignClient { @PostMapping("/resi/group/group/gov-edit-auditing-list") diff --git a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/feign/fallback/ResiGroupOpenFeignClientFallback.java b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/feign/fallback/ResiGroupOpenFeignClientFallback.java index a5e3eb06fe..94f03f3d41 100644 --- a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/feign/fallback/ResiGroupOpenFeignClientFallback.java +++ b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/feign/fallback/ResiGroupOpenFeignClientFallback.java @@ -25,7 +25,7 @@ import java.util.List; * @author yinzuomei@elink-cn.com * @date 2020/6/4 13:17 */ -@Component +//@Component public class ResiGroupOpenFeignClientFallback implements ResiGroupOpenFeignClient { @Override public Result> govEditAuditingList(CommonGridAndPageFormDTO param) { diff --git a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/feign/fallback/ResiGroupOpenFeignClientFallbackFactory.java b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/feign/fallback/ResiGroupOpenFeignClientFallbackFactory.java new file mode 100644 index 0000000000..a0e0c96818 --- /dev/null +++ b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/feign/fallback/ResiGroupOpenFeignClientFallbackFactory.java @@ -0,0 +1,20 @@ +package com.epmet.resi.group.feign.fallback; + +import com.epmet.commons.tools.exception.ExceptionUtils; +import com.epmet.resi.group.feign.ResiGroupOpenFeignClient; +import feign.hystrix.FallbackFactory; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +@Component +@Slf4j +public class ResiGroupOpenFeignClientFallbackFactory implements FallbackFactory { + + private ResiGroupOpenFeignClientFallback fallback = new ResiGroupOpenFeignClientFallback(); + + @Override + public ResiGroupOpenFeignClient create(Throwable cause) { + log.error(String.format("FeignClient调用发生异常,异常信息:%s", ExceptionUtils.getThrowableErrorStackTrace(cause))); + return fallback; + } +} diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/ResiGroupApplication.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/ResiGroupApplication.java index b87b17770f..0976927df0 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/ResiGroupApplication.java +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/ResiGroupApplication.java @@ -10,6 +10,7 @@ package com.epmet; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.web.servlet.ServletComponentScan; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.cloud.openfeign.EnableFeignClients; @@ -22,6 +23,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients; @SpringBootApplication @EnableDiscoveryClient @EnableFeignClients +@ServletComponentScan public class ResiGroupApplication { public static void main(String[] args) { diff --git a/epmet-module/resi-guide/resi-guide-server/src/main/java/com/epmet/ResiGuideApplication.java b/epmet-module/resi-guide/resi-guide-server/src/main/java/com/epmet/ResiGuideApplication.java index f0c424d76a..204b468868 100644 --- a/epmet-module/resi-guide/resi-guide-server/src/main/java/com/epmet/ResiGuideApplication.java +++ b/epmet-module/resi-guide/resi-guide-server/src/main/java/com/epmet/ResiGuideApplication.java @@ -10,6 +10,7 @@ package com.epmet; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.web.servlet.ServletComponentScan; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.cloud.openfeign.EnableFeignClients; @@ -22,6 +23,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients; @SpringBootApplication @EnableDiscoveryClient @EnableFeignClients +@ServletComponentScan public class ResiGuideApplication { public static void main(String[] args) { diff --git a/epmet-module/resi-hall/resi-hall-server/src/main/java/com/epmet/ResiHallApplication.java b/epmet-module/resi-hall/resi-hall-server/src/main/java/com/epmet/ResiHallApplication.java index 83139e9255..c8d91862ce 100644 --- a/epmet-module/resi-hall/resi-hall-server/src/main/java/com/epmet/ResiHallApplication.java +++ b/epmet-module/resi-hall/resi-hall-server/src/main/java/com/epmet/ResiHallApplication.java @@ -2,6 +2,7 @@ package com.epmet; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.web.servlet.ServletComponentScan; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.cloud.openfeign.EnableFeignClients; @@ -14,6 +15,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients; @SpringBootApplication @EnableDiscoveryClient @EnableFeignClients +@ServletComponentScan public class ResiHallApplication { public static void main(String[] args) { diff --git a/epmet-module/resi-home/resi-home-server/src/main/java/com/epmet/ResiHomeApplication.java b/epmet-module/resi-home/resi-home-server/src/main/java/com/epmet/ResiHomeApplication.java index 9c7e8f6a66..43f8938fc8 100644 --- a/epmet-module/resi-home/resi-home-server/src/main/java/com/epmet/ResiHomeApplication.java +++ b/epmet-module/resi-home/resi-home-server/src/main/java/com/epmet/ResiHomeApplication.java @@ -2,6 +2,7 @@ package com.epmet; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.web.servlet.ServletComponentScan; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.cloud.openfeign.EnableFeignClients; @@ -14,6 +15,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients; @SpringBootApplication @EnableDiscoveryClient @EnableFeignClients +@ServletComponentScan public class ResiHomeApplication { public static void main(String[] args) { diff --git a/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/ResiMineApplication.java b/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/ResiMineApplication.java index a8e461d66a..f179e70961 100644 --- a/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/ResiMineApplication.java +++ b/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/ResiMineApplication.java @@ -10,6 +10,7 @@ package com.epmet; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.web.servlet.ServletComponentScan; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.cloud.openfeign.EnableFeignClients; @@ -22,6 +23,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients; @SpringBootApplication @EnableDiscoveryClient @EnableFeignClients +@ServletComponentScan public class ResiMineApplication { public static void main(String[] args) { diff --git a/epmet-module/resi-partymember/resi-partymember-client/src/main/java/com/epmet/resi/partymember/feign/ResiPartyMemberOpenFeignClient.java b/epmet-module/resi-partymember/resi-partymember-client/src/main/java/com/epmet/resi/partymember/feign/ResiPartyMemberOpenFeignClient.java index f823096f15..0eb5f2f018 100644 --- a/epmet-module/resi-partymember/resi-partymember-client/src/main/java/com/epmet/resi/partymember/feign/ResiPartyMemberOpenFeignClient.java +++ b/epmet-module/resi-partymember/resi-partymember-client/src/main/java/com/epmet/resi/partymember/feign/ResiPartyMemberOpenFeignClient.java @@ -9,6 +9,7 @@ import com.epmet.resi.partymember.dto.partymember.form.PartyMemberBaseInfoAddFor import com.epmet.resi.partymember.dto.partymember.result.PartyMemberBaseInfoDetailResultDTO; import com.epmet.resi.partymember.dto.partymember.result.PartymemberBaseInfoResultDTO; import com.epmet.resi.partymember.feign.fallback.ResiPartyMemberOpenFeignClientFallback; +import com.epmet.resi.partymember.feign.fallback.ResiPartyMemberOpenFeignClientFallbackFactory; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.http.MediaType; import org.springframework.web.bind.annotation.*; @@ -21,8 +22,8 @@ import java.util.List; * @author yinzuomei@elink-cn.com * @date 2020/6/4 13:12 */ -//@FeignClient(name = ServiceConstant.RESI_PARTYMEMBER_SERVER, fallback = ResiPartyMemberOpenFeignClientFallback.class,url = "http://localhost:8096") -@FeignClient(name = ServiceConstant.RESI_PARTYMEMBER_SERVER, fallback = ResiPartyMemberOpenFeignClientFallback.class) +//@FeignClient(name = ServiceConstant.RESI_PARTYMEMBER_SERVER, fallbackFactory = ResiPartyMemberOpenFeignClientFallbackFactory.class,url = "http://localhost:8096") +@FeignClient(name = ServiceConstant.RESI_PARTYMEMBER_SERVER, fallbackFactory = ResiPartyMemberOpenFeignClientFallbackFactory.class) public interface ResiPartyMemberOpenFeignClient { /** diff --git a/epmet-module/resi-partymember/resi-partymember-client/src/main/java/com/epmet/resi/partymember/feign/fallback/ResiPartyMemberOpenFeignClientFallback.java b/epmet-module/resi-partymember/resi-partymember-client/src/main/java/com/epmet/resi/partymember/feign/fallback/ResiPartyMemberOpenFeignClientFallback.java index 3f3ebb8c97..9591f35234 100644 --- a/epmet-module/resi-partymember/resi-partymember-client/src/main/java/com/epmet/resi/partymember/feign/fallback/ResiPartyMemberOpenFeignClientFallback.java +++ b/epmet-module/resi-partymember/resi-partymember-client/src/main/java/com/epmet/resi/partymember/feign/fallback/ResiPartyMemberOpenFeignClientFallback.java @@ -20,7 +20,7 @@ import java.util.List; * @author yinzuomei@elink-cn.com * @date 2020/6/4 13:14 */ -@Component +//@Component public class ResiPartyMemberOpenFeignClientFallback implements ResiPartyMemberOpenFeignClient { @Override diff --git a/epmet-module/resi-partymember/resi-partymember-client/src/main/java/com/epmet/resi/partymember/feign/fallback/ResiPartyMemberOpenFeignClientFallbackFactory.java b/epmet-module/resi-partymember/resi-partymember-client/src/main/java/com/epmet/resi/partymember/feign/fallback/ResiPartyMemberOpenFeignClientFallbackFactory.java new file mode 100644 index 0000000000..cbf70d12aa --- /dev/null +++ b/epmet-module/resi-partymember/resi-partymember-client/src/main/java/com/epmet/resi/partymember/feign/fallback/ResiPartyMemberOpenFeignClientFallbackFactory.java @@ -0,0 +1,20 @@ +package com.epmet.resi.partymember.feign.fallback; + +import com.epmet.commons.tools.exception.ExceptionUtils; +import com.epmet.resi.partymember.feign.ResiPartyMemberOpenFeignClient; +import feign.hystrix.FallbackFactory; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +@Component +@Slf4j +public class ResiPartyMemberOpenFeignClientFallbackFactory implements FallbackFactory { + + private ResiPartyMemberOpenFeignClientFallback fallback = new ResiPartyMemberOpenFeignClientFallback(); + + @Override + public ResiPartyMemberOpenFeignClient create(Throwable cause) { + log.error(String.format("FeignClient调用发生异常,异常信息:%s", ExceptionUtils.getThrowableErrorStackTrace(cause))); + return fallback; + } +} diff --git a/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/ResiPartyMemberApplication.java b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/ResiPartyMemberApplication.java index b5fe00951d..57a43e6f1f 100644 --- a/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/ResiPartyMemberApplication.java +++ b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/ResiPartyMemberApplication.java @@ -10,6 +10,7 @@ package com.epmet; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.web.servlet.ServletComponentScan; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.cloud.openfeign.EnableFeignClients; @@ -22,6 +23,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients; @SpringBootApplication @EnableDiscoveryClient @EnableFeignClients +@ServletComponentScan public class ResiPartyMemberApplication { public static void main(String[] args) { diff --git a/epmet-module/resi-voice/resi-voice-client/src/main/java/com/epmet/feign/ResiVoiceOpenFeignClient.java b/epmet-module/resi-voice/resi-voice-client/src/main/java/com/epmet/feign/ResiVoiceOpenFeignClient.java index a31843a85f..accd02d67c 100644 --- a/epmet-module/resi-voice/resi-voice-client/src/main/java/com/epmet/feign/ResiVoiceOpenFeignClient.java +++ b/epmet-module/resi-voice/resi-voice-client/src/main/java/com/epmet/feign/ResiVoiceOpenFeignClient.java @@ -1,5 +1,6 @@ package com.epmet.feign; +import com.epmet.feign.fallback.ResiVoiceOpenFeignClientFallbackFactory; import org.springframework.cloud.openfeign.FeignClient; import com.epmet.commons.tools.constant.ServiceConstant; @@ -11,6 +12,6 @@ import com.epmet.feign.fallback.ResiVoiceOpenFeignClientFallback; * @author yinzuomei@elink-cn.com * @date 2020/6/4 13:01 */ -@FeignClient(name = ServiceConstant.RESI_VOICE_SERVER, fallback = ResiVoiceOpenFeignClientFallback.class) +@FeignClient(name = ServiceConstant.RESI_VOICE_SERVER, fallbackFactory = ResiVoiceOpenFeignClientFallbackFactory.class) public interface ResiVoiceOpenFeignClient { } diff --git a/epmet-module/resi-voice/resi-voice-client/src/main/java/com/epmet/feign/fallback/ResiVoiceOpenFeignClientFallback.java b/epmet-module/resi-voice/resi-voice-client/src/main/java/com/epmet/feign/fallback/ResiVoiceOpenFeignClientFallback.java index f538efd990..71a56f62d2 100644 --- a/epmet-module/resi-voice/resi-voice-client/src/main/java/com/epmet/feign/fallback/ResiVoiceOpenFeignClientFallback.java +++ b/epmet-module/resi-voice/resi-voice-client/src/main/java/com/epmet/feign/fallback/ResiVoiceOpenFeignClientFallback.java @@ -9,6 +9,6 @@ import org.springframework.stereotype.Component; * @author yinzuomei@elink-cn.com * @date 2020/6/4 13:05 */ -@Component +//@Component public class ResiVoiceOpenFeignClientFallback implements ResiVoiceOpenFeignClient { } diff --git a/epmet-module/resi-voice/resi-voice-client/src/main/java/com/epmet/feign/fallback/ResiVoiceOpenFeignClientFallbackFactory.java b/epmet-module/resi-voice/resi-voice-client/src/main/java/com/epmet/feign/fallback/ResiVoiceOpenFeignClientFallbackFactory.java new file mode 100644 index 0000000000..3a896e05b6 --- /dev/null +++ b/epmet-module/resi-voice/resi-voice-client/src/main/java/com/epmet/feign/fallback/ResiVoiceOpenFeignClientFallbackFactory.java @@ -0,0 +1,18 @@ +package com.epmet.feign.fallback; + +import com.epmet.commons.tools.exception.ExceptionUtils; +import com.epmet.feign.ResiVoiceOpenFeignClient; +import feign.hystrix.FallbackFactory; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +@Component +@Slf4j +public class ResiVoiceOpenFeignClientFallbackFactory implements FallbackFactory { + private ResiVoiceOpenFeignClientFallback fallback = new ResiVoiceOpenFeignClientFallback(); + @Override + public ResiVoiceOpenFeignClient create(Throwable cause) { + log.error(String.format("FeignClient调用发生异常,异常信息:%s", ExceptionUtils.getThrowableErrorStackTrace(cause))); + return fallback; + } +} diff --git a/epmet-module/resi-voice/resi-voice-server/src/main/java/com/epmet/ResiVoiceApplication.java b/epmet-module/resi-voice/resi-voice-server/src/main/java/com/epmet/ResiVoiceApplication.java index 27d6017d9a..8dcdc0c704 100644 --- a/epmet-module/resi-voice/resi-voice-server/src/main/java/com/epmet/ResiVoiceApplication.java +++ b/epmet-module/resi-voice/resi-voice-server/src/main/java/com/epmet/ResiVoiceApplication.java @@ -2,6 +2,7 @@ package com.epmet; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.web.servlet.ServletComponentScan; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.cloud.openfeign.EnableFeignClients; @@ -13,6 +14,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients; @SpringBootApplication @EnableDiscoveryClient @EnableFeignClients +@ServletComponentScan public class ResiVoiceApplication { public static void main(String[] args) { SpringApplication.run(ResiVoiceApplication.class, args); diff --git a/epmet-openapi/epmet-openapi-scan/src/main/java/com/epmet/openapi/scan/ScanApplication.java b/epmet-openapi/epmet-openapi-scan/src/main/java/com/epmet/openapi/scan/ScanApplication.java index 38f55211d2..7b088fe970 100644 --- a/epmet-openapi/epmet-openapi-scan/src/main/java/com/epmet/openapi/scan/ScanApplication.java +++ b/epmet-openapi/epmet-openapi-scan/src/main/java/com/epmet/openapi/scan/ScanApplication.java @@ -10,6 +10,7 @@ package com.epmet.openapi.scan; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.web.servlet.ServletComponentScan; import org.springframework.context.annotation.ComponentScan; /** @@ -21,6 +22,7 @@ import org.springframework.context.annotation.ComponentScan; @SpringBootApplication @ComponentScan(basePackages = "com.epmet") +@ServletComponentScan public class ScanApplication { public static void main(String[] args) { diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java index 6cfb21aa99..e111a8fb6c 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java @@ -7,7 +7,7 @@ import com.epmet.commons.tools.utils.Result; import com.epmet.dto.*; import com.epmet.dto.form.*; import com.epmet.dto.result.*; -import com.epmet.feign.fallback.EpmetUserOpenFeignClientFallback; +import com.epmet.feign.fallback.EpmetUserOpenFeignClientFallbackFactory; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.http.MediaType; import org.springframework.web.bind.annotation.*; @@ -21,8 +21,8 @@ import java.util.Map; * @author yinzuomei@elink-cn.com * @date 2020/6/4 13:09 */ -//@FeignClient(name = ServiceConstant.EPMET_USER_SERVER, fallback = EpmetUserOpenFeignClientFallback.class, url = "localhost:8087") -@FeignClient(name = ServiceConstant.EPMET_USER_SERVER, fallback = EpmetUserOpenFeignClientFallback.class) +//@FeignClient(name = ServiceConstant.EPMET_USER_SERVER, fallbackFactory = EpmetUserOpenFeignClientFallbackFactory.class, url = "localhost:8087") +@FeignClient(name = ServiceConstant.EPMET_USER_SERVER, fallbackFactory = EpmetUserOpenFeignClientFallbackFactory.class) public interface EpmetUserOpenFeignClient { /** diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java index b0b8723f01..7398ecb56c 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java @@ -19,7 +19,7 @@ import java.util.Map; * @author yinzuomei@elink-cn.com * @date 2020/6/4 13:10 */ -@Component +//@Component public class EpmetUserOpenFeignClientFallback implements EpmetUserOpenFeignClient { @Override diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallbackFactory.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallbackFactory.java new file mode 100644 index 0000000000..9f752bc056 --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallbackFactory.java @@ -0,0 +1,18 @@ +package com.epmet.feign.fallback; + +import com.epmet.commons.tools.exception.ExceptionUtils; +import com.epmet.feign.EpmetUserOpenFeignClient; +import feign.hystrix.FallbackFactory; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +@Component +@Slf4j +public class EpmetUserOpenFeignClientFallbackFactory implements FallbackFactory { + private EpmetUserOpenFeignClientFallback fallback = new EpmetUserOpenFeignClientFallback(); + @Override + public EpmetUserOpenFeignClient create(Throwable cause) { + log.error(String.format("FeignClient调用发生异常,异常信息:%s", ExceptionUtils.getThrowableErrorStackTrace(cause))); + return fallback; + } +} diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/UserApplication.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/UserApplication.java index 8f8e583add..106c49d028 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/UserApplication.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/UserApplication.java @@ -10,6 +10,7 @@ package com.epmet; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.web.servlet.ServletComponentScan; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.cloud.openfeign.EnableFeignClients; @@ -23,6 +24,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients; @SpringBootApplication @EnableDiscoveryClient @EnableFeignClients +@ServletComponentScan public class UserApplication { public static void main(String[] args) {