diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2774c22d2..b4b04b45c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,4 @@
# Change Log
---
-- [Add metadata transfer example.](https://github.com/Tencent/spring-cloud-tencent/pull/209)
-- [feat:merge features from 1.5.2-Hoxton.SR9.](https://github.com/Tencent/spring-cloud-tencent/pull/223)
+- [fix: fix not load application.yml bug & fix guava version conflict bug.](https://github.com/Tencent/spring-cloud-tencent/pull/286)
diff --git a/changes/changes-1.5.2.md b/changes/changes-1.5.2.md
new file mode 100644
index 000000000..02afad1a6
--- /dev/null
+++ b/changes/changes-1.5.2.md
@@ -0,0 +1,5 @@
+# Change Log
+---
+
+- [fix:use 1.6.1 version of polaris-java.](https://github.com/Tencent/spring-cloud-tencent/pull/209)
+- [fix:use 1.6.1 version of polaris-java and fix some bug.](https://github.com/Tencent/spring-cloud-tencent/pull/223)
diff --git a/pom.xml b/pom.xml
index 946a94933..cbe5eb91e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -38,9 +38,11 @@
- spring-cloud-tencent-polaris-context
spring-cloud-tencent-commons
+ spring-cloud-tencent-polaris-context
+ spring-cloud-tencent-polaris-loadbalancer
spring-cloud-starter-tencent-metadata-transfer
+ spring-cloud-starter-tencent-polaris-config
spring-cloud-starter-tencent-polaris-discovery
spring-cloud-starter-tencent-polaris-ratelimit
spring-cloud-starter-tencent-polaris-circuitbreaker
@@ -48,8 +50,6 @@
spring-cloud-tencent-dependencies
spring-cloud-tencent-examples
spring-cloud-tencent-coverage
- spring-cloud-starter-tencent-polaris-config
- spring-cloud-tencent-polaris-loadbalancer
@@ -86,7 +86,7 @@
- 1.5.2-Greenwich.SR6
+ 1.5.3-Greenwich.SR6
Greenwich.SR6
diff --git a/spring-cloud-starter-tencent-metadata-transfer/src/test/java/com/tencent/cloud/metadata/core/intercepter/EncodeTransferMedataFeignInterceptorTest.java b/spring-cloud-starter-tencent-metadata-transfer/src/test/java/com/tencent/cloud/metadata/core/intercepter/EncodeTransferMedataFeignInterceptorTest.java
index ca9671631..ef70e38c7 100644
--- a/spring-cloud-starter-tencent-metadata-transfer/src/test/java/com/tencent/cloud/metadata/core/intercepter/EncodeTransferMedataFeignInterceptorTest.java
+++ b/spring-cloud-starter-tencent-metadata-transfer/src/test/java/com/tencent/cloud/metadata/core/intercepter/EncodeTransferMedataFeignInterceptorTest.java
@@ -19,9 +19,10 @@
package com.tencent.cloud.metadata.core.intercepter;
import java.io.UnsupportedEncodingException;
-import java.net.URLDecoder;
import com.tencent.cloud.common.constant.MetadataConstant;
+import com.tencent.cloud.common.metadata.MetadataContext;
+import com.tencent.cloud.common.metadata.MetadataContextHolder;
import com.tencent.cloud.common.metadata.config.MetadataLocalProperties;
import com.tencent.cloud.metadata.core.EncodeTransferMedataFeignInterceptor;
import feign.RequestInterceptor;
@@ -62,10 +63,9 @@ public class EncodeTransferMedataFeignInterceptorTest {
private TestApplication.TestFeign testFeign;
@Test
- public void test1() {
+ public void testTransitiveMetadataFromApplicationConfig() {
String metadata = testFeign.test();
- Assertions.assertThat(metadata)
- .isEqualTo("{\"b\":\"2\"}");
+ Assertions.assertThat(metadata).isEqualTo("2");
Assertions.assertThat(metadataLocalProperties.getContent().get("a"))
.isEqualTo("1");
Assertions.assertThat(metadataLocalProperties.getContent().get("b"))
@@ -81,16 +81,13 @@ public class EncodeTransferMedataFeignInterceptorTest {
public String test(
@RequestHeader(MetadataConstant.HeaderName.CUSTOM_METADATA) String customMetadataStr)
throws UnsupportedEncodingException {
- return URLDecoder.decode(customMetadataStr, "UTF-8");
+ return MetadataContextHolder.get().getContext(MetadataContext.FRAGMENT_TRANSITIVE, "b");
}
@FeignClient(name = "test-feign", url = "http://localhost:8081")
public interface TestFeign {
- @RequestMapping(value = "/test",
- headers = {"X-SCT-Metadata-Transitive-a=11",
- "X-SCT-Metadata-Transitive-b=22",
- "X-SCT-Metadata-Transitive-c=33"})
+ @RequestMapping("/test")
String test();
}
diff --git a/spring-cloud-starter-tencent-metadata-transfer/src/test/java/com/tencent/cloud/metadata/core/intercepter/EncodeTransferMedataRestTemplateInterceptorTest.java b/spring-cloud-starter-tencent-metadata-transfer/src/test/java/com/tencent/cloud/metadata/core/intercepter/EncodeTransferMedataRestTemplateInterceptorTest.java
index ba5524c9a..78abb33ab 100644
--- a/spring-cloud-starter-tencent-metadata-transfer/src/test/java/com/tencent/cloud/metadata/core/intercepter/EncodeTransferMedataRestTemplateInterceptorTest.java
+++ b/spring-cloud-starter-tencent-metadata-transfer/src/test/java/com/tencent/cloud/metadata/core/intercepter/EncodeTransferMedataRestTemplateInterceptorTest.java
@@ -19,11 +19,12 @@
package com.tencent.cloud.metadata.core.intercepter;
import java.io.UnsupportedEncodingException;
-import java.net.URLDecoder;
import com.tencent.cloud.common.constant.MetadataConstant;
-import com.tencent.cloud.common.metadata.config.MetadataLocalProperties;
+import com.tencent.cloud.common.metadata.MetadataContext;
+import com.tencent.cloud.common.metadata.MetadataContextHolder;
import com.tencent.cloud.metadata.core.EncodeTransferMedataRestTemplateInterceptor;
+import org.assertj.core.api.Assertions;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -32,6 +33,9 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.context.annotation.Bean;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpMethod;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -51,9 +55,6 @@ import static org.springframework.boot.test.context.SpringBootTest.WebEnvironmen
properties = { "spring.config.location = classpath:application-test.yml" })
public class EncodeTransferMedataRestTemplateInterceptorTest {
- @Autowired
- private MetadataLocalProperties metadataLocalProperties;
-
@Autowired
private RestTemplate restTemplate;
@@ -61,30 +62,14 @@ public class EncodeTransferMedataRestTemplateInterceptorTest {
private int localServerPort;
@Test
- public void test1() {
-// HttpHeaders httpHeaders = new HttpHeaders();
-// httpHeaders.set(MetadataConstant.HeaderName.CUSTOM_METADATA,
-// "{\"a\":\"11\",\"b\":\"22\",\"c\":\"33\"}");
-// HttpEntity httpEntity = new HttpEntity<>(httpHeaders);
-// String metadata = restTemplate
-// .exchange("http://localhost:" + localServerPort + "/test", HttpMethod.GET,
-// httpEntity, String.class)
-// .getBody();
-// Assertions.assertThat(metadata)
-// .isEqualTo("{\"a\":\"11\",\"b\":\"22\",\"c\":\"33\"}");
-// Assertions.assertThat(metadataLocalProperties.getContent().get("a"))
-// .isEqualTo("1");
-// Assertions.assertThat(metadataLocalProperties.getContent().get("b"))
-// .isEqualTo("2");
-// Assertions
-// .assertThat(MetadataContextHolder.get().getContext(MetadataContext.FRAGMENT_TRANSITIVE, "a"))
-// .isEqualTo("11");
-// Assertions
-// .assertThat(MetadataContextHolder.get().getContext(MetadataContext.FRAGMENT_TRANSITIVE, "b"))
-// .isEqualTo("22");
-// Assertions
-// .assertThat(MetadataContextHolder.get().getContext(MetadataContext.FRAGMENT_TRANSITIVE, "c"))
-// .isEqualTo("33");
+ public void testTransitiveMetadataFromApplicationConfig() {
+ HttpHeaders httpHeaders = new HttpHeaders();
+ HttpEntity httpEntity = new HttpEntity<>(httpHeaders);
+ String metadata = restTemplate
+ .exchange("http://localhost:" + localServerPort + "/test", HttpMethod.GET,
+ httpEntity, String.class)
+ .getBody();
+ Assertions.assertThat(metadata).isEqualTo("2");
}
@SpringBootApplication
@@ -100,7 +85,7 @@ public class EncodeTransferMedataRestTemplateInterceptorTest {
public String test(
@RequestHeader(MetadataConstant.HeaderName.CUSTOM_METADATA) String customMetadataStr)
throws UnsupportedEncodingException {
- return URLDecoder.decode(customMetadataStr, "UTF-8");
+ return MetadataContextHolder.get().getContext(MetadataContext.FRAGMENT_TRANSITIVE, "b");
}
}
diff --git a/spring-cloud-starter-tencent-polaris-config/pom.xml b/spring-cloud-starter-tencent-polaris-config/pom.xml
index 10b362a67..a7f0e5894 100644
--- a/spring-cloud-starter-tencent-polaris-config/pom.xml
+++ b/spring-cloud-starter-tencent-polaris-config/pom.xml
@@ -11,6 +11,7 @@
4.0.0
spring-cloud-starter-tencent-polaris-config
+ Spring Cloud Starter Tencent Polaris Config
@@ -64,5 +65,28 @@
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+
+ org.mockito
+ mockito-inline
+ test
+
+
+
+ org.mockito
+ mockito-core
+ test
+
+
+
+ net.bytebuddy
+ byte-buddy
+ test
+
diff --git a/spring-cloud-starter-tencent-polaris-config/src/main/java/com/tencent/cloud/polaris/config/PolarisConfigBootstrapAutoConfiguration.java b/spring-cloud-starter-tencent-polaris-config/src/main/java/com/tencent/cloud/polaris/config/PolarisConfigBootstrapAutoConfiguration.java
index 3f8eafceb..dfa4eb823 100644
--- a/spring-cloud-starter-tencent-polaris-config/src/main/java/com/tencent/cloud/polaris/config/PolarisConfigBootstrapAutoConfiguration.java
+++ b/spring-cloud-starter-tencent-polaris-config/src/main/java/com/tencent/cloud/polaris/config/PolarisConfigBootstrapAutoConfiguration.java
@@ -51,16 +51,18 @@ public class PolarisConfigBootstrapAutoConfiguration {
}
@Bean
- public ConfigFileService configFileService(SDKContext sdkContext) {
- return ConfigFileServiceFactory.createConfigFileService(sdkContext);
+ public PolarisPropertySourceManager polarisPropertySourceManager() {
+ return new PolarisPropertySourceManager();
}
@Bean
- public PolarisPropertySourceManager polarisPropertySourceManager() {
- return new PolarisPropertySourceManager();
+ @ConditionalOnConnectRemoteServerEnabled
+ public ConfigFileService configFileService(SDKContext sdkContext) {
+ return ConfigFileServiceFactory.createConfigFileService(sdkContext);
}
@Bean
+ @ConditionalOnConnectRemoteServerEnabled
public PolarisConfigFileLocator polarisConfigFileLocator(
PolarisConfigProperties polarisConfigProperties,
PolarisContextProperties polarisContextProperties,
@@ -73,6 +75,7 @@ public class PolarisConfigBootstrapAutoConfiguration {
}
@Bean
+ @ConditionalOnConnectRemoteServerEnabled
public ConfigurationModifier configurationModifier(PolarisConfigProperties polarisConfigProperties,
PolarisContextProperties polarisContextProperties) {
return new ConfigurationModifier(polarisConfigProperties, polarisContextProperties);
diff --git a/spring-cloud-starter-tencent-polaris-config/src/main/java/com/tencent/cloud/polaris/config/adapter/PolarisConfigFileLocator.java b/spring-cloud-starter-tencent-polaris-config/src/main/java/com/tencent/cloud/polaris/config/adapter/PolarisConfigFileLocator.java
index cad31d1de..240eb4cc0 100644
--- a/spring-cloud-starter-tencent-polaris-config/src/main/java/com/tencent/cloud/polaris/config/adapter/PolarisConfigFileLocator.java
+++ b/spring-cloud-starter-tencent-polaris-config/src/main/java/com/tencent/cloud/polaris/config/adapter/PolarisConfigFileLocator.java
@@ -84,13 +84,14 @@ public class PolarisConfigFileLocator implements PropertySourceLocator {
CompositePropertySource compositePropertySource = new CompositePropertySource(
POLARIS_CONFIG_PROPERTY_SOURCE_NAME);
+ // load spring boot default config files
+ initInternalConfigFiles(compositePropertySource);
+
+ // load custom config files
List configFileGroups = polarisConfigProperties.getGroups();
if (CollectionUtils.isEmpty(configFileGroups)) {
return compositePropertySource;
}
-
- initInternalConfigFiles(compositePropertySource);
-
initCustomPolarisConfigFiles(compositePropertySource, configFileGroups);
return compositePropertySource;
@@ -190,12 +191,10 @@ public class PolarisConfigFileLocator implements PropertySourceLocator {
// unknown extension is resolved as properties file
if (ConfigFileFormat.isPropertyFile(fileName)
|| ConfigFileFormat.isUnknownFile(fileName)) {
- configKVFile = configFileService.getConfigPropertiesFile(namespace, group,
- fileName);
+ configKVFile = configFileService.getConfigPropertiesFile(namespace, group, fileName);
}
else if (ConfigFileFormat.isYamlFile(fileName)) {
- configKVFile = configFileService.getConfigYamlFile(namespace, group,
- fileName);
+ configKVFile = configFileService.getConfigYamlFile(namespace, group, fileName);
}
else {
LOGGER.warn(
diff --git a/spring-cloud-starter-tencent-polaris-config/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/spring-cloud-starter-tencent-polaris-config/src/main/resources/META-INF/additional-spring-configuration-metadata.json
index ee84cbd47..9954a62ce 100644
--- a/spring-cloud-starter-tencent-polaris-config/src/main/resources/META-INF/additional-spring-configuration-metadata.json
+++ b/spring-cloud-starter-tencent-polaris-config/src/main/resources/META-INF/additional-spring-configuration-metadata.json
@@ -34,6 +34,13 @@
"defaultValue": "",
"description": "List of imported config files.",
"sourceType": "com.tencent.cloud.polaris.config.config.PolarisConfigProperties"
+ },
+ {
+ "name": "spring.cloud.polaris.config.connect-remote-server",
+ "type": "java.lang.Boolean",
+ "defaultValue": "true",
+ "description": "Whether to connect to a remote server, suitable for local development mode.",
+ "sourceType": "com.tencent.cloud.polaris.config.config.PolarisConfigProperties"
}
]
}
diff --git a/spring-cloud-starter-tencent-polaris-config/src/test/resources/application-test.yml b/spring-cloud-starter-tencent-polaris-config/src/test/resources/application-test.yml
new file mode 100644
index 000000000..c90d1340b
--- /dev/null
+++ b/spring-cloud-starter-tencent-polaris-config/src/test/resources/application-test.yml
@@ -0,0 +1,9 @@
+spring:
+ application:
+ name: test
+ cloud:
+ polaris:
+ address: grpc://127.0.0.1:8091
+ namespace: default
+ config:
+ connect-remote-server: false
diff --git a/spring-cloud-tencent-coverage/pom.xml b/spring-cloud-tencent-coverage/pom.xml
index 1c8ba0ed4..37903c143 100644
--- a/spring-cloud-tencent-coverage/pom.xml
+++ b/spring-cloud-tencent-coverage/pom.xml
@@ -24,6 +24,16 @@
spring-cloud-tencent-commons
+
+ com.tencent.cloud
+ spring-cloud-tencent-polaris-context
+
+
+
+ com.tencent.cloud
+ spring-cloud-tencent-polaris-loadbalancer
+
+
com.tencent.cloud
spring-cloud-starter-tencent-polaris-discovery
@@ -49,10 +59,10 @@
spring-cloud-starter-tencent-polaris-router
-
- com.tencent.cloud
- spring-cloud-tencent-polaris-context
-
+
+ com.tencent.cloud
+ spring-cloud-starter-tencent-polaris-config
+
@@ -75,4 +85,4 @@
-
\ No newline at end of file
+
diff --git a/spring-cloud-tencent-dependencies/pom.xml b/spring-cloud-tencent-dependencies/pom.xml
index db59ed3a2..f744c59f3 100644
--- a/spring-cloud-tencent-dependencies/pom.xml
+++ b/spring-cloud-tencent-dependencies/pom.xml
@@ -70,7 +70,7 @@
- 1.5.2-Greenwich.SR6
+ 1.5.3-Greenwich.SR6
1.6.1
@@ -80,7 +80,7 @@
2.2.6.RELEASE
4.5.1
1.12.10
-
+ 31.0.1-jre
3.2.0
1.2.7
@@ -184,6 +184,32 @@
${revision}
+
+
+ com.google.guava
+ guava
+ ${guava.version}
+
+
+ jsr305
+ com.google.code.findbugs
+
+
+ animal-sniffer-annotations
+ org.codehaus.mojo
+
+
+ error_prone_annotations
+ com.google.errorprone
+
+
+
+
+
+ ch.qos.logback
+ logback-classic
+ ${logback.version}
+
org.mockito