From 5e2683d88bd1e10824f5e76f49c32160845626af Mon Sep 17 00:00:00 2001 From: tanghc Date: Tue, 18 Aug 2020 15:27:46 +0800 Subject: [PATCH] 4.0.3 --- .../configuration/ServiceConfiguration.java | 26 ------------------- .../configuration/SpringmvcConfiguration.java | 1 + 2 files changed, 1 insertion(+), 26 deletions(-) diff --git a/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/configuration/ServiceConfiguration.java b/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/configuration/ServiceConfiguration.java index 1f302e88..37305771 100644 --- a/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/configuration/ServiceConfiguration.java +++ b/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/configuration/ServiceConfiguration.java @@ -1,16 +1,6 @@ package com.gitee.sop.servercommon.configuration; -import com.alibaba.cloud.nacos.NacosDiscoveryProperties; -import com.alibaba.cloud.nacos.discovery.NacosWatch; import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.ObjectProvider; -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; -import org.springframework.context.annotation.Bean; -import org.springframework.core.env.Environment; -import org.springframework.scheduling.TaskScheduler; - -import java.util.Map; /** * @author tanghc @@ -18,20 +8,4 @@ import java.util.Map; @Slf4j public class ServiceConfiguration extends SpringmvcConfiguration { - @Bean - @ConditionalOnMissingBean - @ConditionalOnProperty("spring.cloud.nacos.discovery.server-addr") - public NacosWatch nacosWatch(NacosDiscoveryProperties nacosDiscoveryProperties, ObjectProvider taskScheduler, Environment environment) { - Map metadata = nacosDiscoveryProperties.getMetadata(); - String contextPath = environment.getProperty(METADATA_SERVER_CONTEXT_PATH); - // 将context-path信息加入到metadata中 - if (contextPath != null) { - metadata.put(METADATA_SERVER_CONTEXT_PATH, contextPath); - } - // 在元数据中新增启动时间,不能修改这个值,不然网关拉取接口会有问题 - // 如果没有这个值,网关会忽略这个服务 - metadata.put("server.startup-time", String.valueOf(System.currentTimeMillis())); - return new NacosWatch(nacosDiscoveryProperties, taskScheduler); - } - } diff --git a/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/configuration/SpringmvcConfiguration.java b/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/configuration/SpringmvcConfiguration.java index 4162f0f8..8bea9caa 100644 --- a/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/configuration/SpringmvcConfiguration.java +++ b/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/configuration/SpringmvcConfiguration.java @@ -26,6 +26,7 @@ public class SpringmvcConfiguration implements WebMvcConfigurer { public static final String METADATA_SERVER_CONTEXT_PATH = "server.servlet.context-path"; public SpringmvcConfiguration() { + System.setProperty("eureka.instance.metadata-map.server.startup-time", String.valueOf(System.currentTimeMillis())); ServiceConfig.getInstance().getI18nModules().add("i18n/isp/bizerror"); }