From 90d2e705b935359933802001a77acb8bdc71a50b Mon Sep 17 00:00:00 2001
From: java110 <928255095@qq.com>
Date: 星期六, 17 九月 2022 15:52:44 +0800
Subject: [PATCH] 优化代码
---
service-user/src/main/java/com/java110/user/UserServiceApplicationStart.java | 40 ++++++++++++++++++++++++++++------------
1 files changed, 28 insertions(+), 12 deletions(-)
diff --git a/service-user/src/main/java/com/java110/user/UserServiceApplicationStart.java b/service-user/src/main/java/com/java110/user/UserServiceApplicationStart.java
old mode 100644
new mode 100755
index 484f789..42905a1
--- a/service-user/src/main/java/com/java110/user/UserServiceApplicationStart.java
+++ b/service-user/src/main/java/com/java110/user/UserServiceApplicationStart.java
@@ -1,11 +1,16 @@
package com.java110.user;
+import com.java110.core.annotation.Java110CmdDiscovery;
import com.java110.core.annotation.Java110ListenerDiscovery;
+import com.java110.core.trace.Java110RestTemplateInterceptor;
import com.java110.core.client.RestTemplate;
+import com.java110.core.event.cmd.ServiceCmdEventPublishing;
import com.java110.core.event.service.BusinessServiceDataFlowEventPublishing;
+import com.java110.doc.annotation.Java110CmdDocDiscovery;
+import com.java110.doc.registrar.ApiDocCmdPublishing;
import com.java110.service.init.ServiceStartInit;
import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import com.java110.core.log.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.client.RestTemplateBuilder;
@@ -16,6 +21,7 @@
import org.springframework.context.annotation.Bean;
import org.springframework.http.converter.StringHttpMessageConverter;
+import javax.annotation.Resource;
import java.nio.charset.Charset;
@@ -35,13 +41,33 @@
@EnableDiscoveryClient
@Java110ListenerDiscovery(listenerPublishClass = BusinessServiceDataFlowEventPublishing.class,
basePackages = {"com.java110.user.listener"})
+@Java110CmdDiscovery(cmdPublishClass = ServiceCmdEventPublishing.class,
+ basePackages = {"com.java110.user.cmd"})
@EnableFeignClients(basePackages = {"com.java110.intf.community","com.java110.intf.common","com.java110.intf.store",
"com.java110.intf.fee","com.java110.intf.order"})
+
+// 鏂囨。
+@Java110CmdDocDiscovery(basePackages = {"com.java110.user.cmd"},cmdDocClass = ApiDocCmdPublishing.class)
public class UserServiceApplicationStart {
private static Logger logger = LoggerFactory.getLogger(UserServiceApplicationStart.class);
private static final String LISTENER_PATH = "java110.UserService.listeners";
+
+ @Resource
+ private Java110RestTemplateInterceptor java110RestTemplateInterceptor;
+
+ public static void main(String[] args) throws Exception {
+ try {
+ ServiceStartInit.preInitSystemConfig();
+ ApplicationContext context = SpringApplication.run(UserServiceApplicationStart.class, args);
+ ServiceStartInit.initSystemConfig(context);
+ //鍔犺浇涓氬姟渚﹀惉
+ // SystemStartLoadBusinessConfigure.initSystemConfig(LISTENER_PATH);
+ } catch (Throwable e) {
+ logger.error("绯荤粺鍚姩澶辫触", e);
+ }
+ }
/**
* 瀹炰緥鍖朢estTemplate锛岄�氳繃@LoadBalanced娉ㄨВ寮�鍚潎琛¤礋杞借兘鍔�.
@@ -53,17 +79,7 @@
public RestTemplate restTemplate() {
StringHttpMessageConverter m = new StringHttpMessageConverter(Charset.forName("UTF-8"));
RestTemplate restTemplate = new RestTemplateBuilder().additionalMessageConverters(m).build(RestTemplate.class);
+ restTemplate.getInterceptors().add(java110RestTemplateInterceptor);
return restTemplate;
- }
-
- public static void main(String[] args) throws Exception {
- try {
- ApplicationContext context = SpringApplication.run(UserServiceApplicationStart.class, args);
- ServiceStartInit.initSystemConfig(context);
- //鍔犺浇涓氬姟渚﹀惉
- // SystemStartLoadBusinessConfigure.initSystemConfig(LISTENER_PATH);
- } catch (Throwable e) {
- logger.error("绯荤粺鍚姩澶辫触", e);
- }
}
}
\ No newline at end of file
--
Gitblit v1.8.0