diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml index 7f635f05..011787bd 100644 --- a/.github/workflows/codecov.yml +++ b/.github/workflows/codecov.yml @@ -3,33 +3,34 @@ name: Codecov on: push: branches: - - hoxton + - 2022.0 - 2021.0 - 2020.0 + - hoxton - greenwich pull_request: branches: - - hoxton + - 2022.0 - 2021.0 - 2020.0 + - hoxton - greenwich jobs: - build: + codecov: runs-on: ubuntu-latest steps: - name: Checkout codes uses: actions/checkout@v3 - - name: Set up JDK 8 + - name: Set up JDK 17 uses: actions/setup-java@v3 with: distribution: 'temurin' - java-version: 8 + java-version: 17 - name: Test with Maven - run: mvn clean test -f pom.xml -B -P sonatype -U + run: mvn clean test -B -U -Psonatype - name: Upload coverage to Codecov uses: codecov/codecov-action@v3 with: - token: ${{ secrets.CODECOV_TOKEN }} files: ${{ github.workspace }}/target/site/jacoco/jacoco.xml diff --git a/.github/workflows/junit_test.yml b/.github/workflows/junit_test.yml index 13f2c7ae..c26f1d8b 100644 --- a/.github/workflows/junit_test.yml +++ b/.github/workflows/junit_test.yml @@ -18,7 +18,7 @@ on: - greenwich jobs: - build: + junit: strategy: matrix: java: [ 8, 11, 17 ] @@ -42,4 +42,5 @@ jobs: restore-keys: | ${{ runner.os }}-maven- - name: Test with Maven - run: mvn clean test -f pom.xml -B -P sonatype -U + run: mvn clean test -B -U -Psonatype + diff --git a/.github/workflows/snapshot.yml b/.github/workflows/snapshot.yml new file mode 100644 index 00000000..2b2f5370 --- /dev/null +++ b/.github/workflows/snapshot.yml @@ -0,0 +1,30 @@ +name: Snapshot + +on: + push: + branches: + - 2022.0 + - 2021.0 + - 2020.0 + - hoxton + - greenwich + +jobs: + snapshot: + runs-on: ubuntu-latest + steps: + - name: Checkout codes + uses: actions/checkout@v3 + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + server-id: nexus-snapshots + server-username: MAVEN_USERNAME + server-password: MAVEN_PASSWORD + - name: Publish package + run: mvn clean deploy -B -U -Psonatype + env: + MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }} + MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }} \ No newline at end of file diff --git a/README-zh.md b/README-zh.md index 2daeb122..eda0cb20 100644 --- a/README-zh.md +++ b/README-zh.md @@ -5,7 +5,7 @@ [![Contributors](https://img.shields.io/github/contributors/Tencent/spring-cloud-tencent)](https://github.com/Tencent/spring-cloud-tencent/graphs/contributors) [![License](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](https://opensource.org/licenses/BSD-3-Clause) -[![Build Status](https://github.com/Tencent/spring-cloud-tencent/actions/workflows/junit_test.yml/badge.svg)](https://github.com/Tencent/spring-cloud-tencent/actions/workflows/junit_test.yml) +[![Test with Junit](https://github.com/Tencent/spring-cloud-tencent/actions/workflows/junit_test.yml/badge.svg)](https://github.com/Tencent/spring-cloud-tencent/actions/workflows/junit_test.yml) [![codecov.io](https://codecov.io/gh/Tencent/spring-cloud-tencent/branch/hoxton/graph/badge.svg)](https://codecov.io/gh/Tencent/spring-cloud-tencent?branch=hoxton) [English](./README.md) | 简体中文 @@ -14,12 +14,14 @@ ## 介绍 +> 欢迎各位同学点击右上角 Star 按钮,持续关注我们的项目,给予我们最大的支持~ + Spring Cloud Tencent 是腾讯开源的一站式微服务解决方案。 Spring Cloud Tencent 实现了Spring Cloud 标准微服务 SPI,开发者可以基于 Spring Cloud Tencent 快速开发 Spring Cloud 云原生分布式应用。 -Spring Cloud Tencent 的核心依托腾讯开源的一站式服务发现与治理平台 [Polaris](https://github.com/polarismesh/polaris) +Spring Cloud Tencent 的核心依托腾讯开源的一站式服务发现与治理平台 [PolarisMesh](https://polarismesh.cn/) ,实现各种分布式微服务场景。 - [Polaris Github home page](https://github.com/polarismesh/polaris) @@ -60,6 +62,8 @@ Spring Cloud Tencent 所有组件都已上传到 Maven 中央仓库,只需要 > 注意: > +> 支持Spring Cloud 版本:2022.0、2021.0、2020.0、Hoxton。 +> > Spring Cloud Tencent > 的版本列表可以查看 > [Spring Cloud Tencent 版本管理](https://github.com/Tencent/spring-cloud-tencent/wiki/Spring-Cloud-Tencent-%E7%89%88%E6%9C%AC%E7%AE%A1%E7%90%86) @@ -75,7 +79,7 @@ Spring Cloud Tencent 所有组件都已上传到 Maven 中央仓库,只需要 com.tencent.cloud spring-cloud-tencent-dependencies - 1.9.0-Hoxton.SR12 + 1.9.1-Hoxton.SR12 pom import @@ -106,27 +110,7 @@ You can build this project with command: ## 文档 -- 使用文档 - - [Spring Cloud Tencent 版本管理](https://github.com/Tencent/spring-cloud-tencent/wiki/Spring-Cloud-Tencent-%E7%89%88%E6%9C%AC%E7%AE%A1%E7%90%86) - - [服务注册与发现](https://github.com/Tencent/spring-cloud-tencent/wiki/Spring-Cloud-Tencent-Discovery-%E4%BD%BF%E7%94%A8%E6%96%87%E6%A1%A3) - - [配置中心](https://github.com/Tencent/spring-cloud-tencent/wiki/Spring-Cloud-Tencent-Config-%E4%BD%BF%E7%94%A8%E6%96%87%E6%A1%A3) - - [服务限流](https://github.com/Tencent/spring-cloud-tencent/wiki/Spring-Cloud-Tencent-Rate-Limit-%E4%BD%BF%E7%94%A8%E6%96%87%E6%A1%A3) - - [服务熔断](https://github.com/Tencent/spring-cloud-tencent/wiki/Spring-Cloud-Tencent-Circuitbreaker-%E4%BD%BF%E7%94%A8%E6%96%87%E6%A1%A3) - - [服务路由](https://github.com/Tencent/spring-cloud-tencent/wiki/Spring-Cloud-Tencent-Router-%E4%BD%BF%E7%94%A8%E6%96%87%E6%A1%A3) - - [RPC增强](https://github.com/Tencent/spring-cloud-tencent/wiki/RPC%E5%A2%9E%E5%BC%BA) - - [元数据传递](https://github.com/Tencent/spring-cloud-tencent/wiki/Spring-Cloud-Tencent-Metadata-Transfer-%E4%BD%BF%E7%94%A8%E6%8C%87%E5%8D%97) - - [场景化插件](https://github.com/Tencent/spring-cloud-tencent/wiki/场景化插件) - - [Actuator Endpoint 扩展](https://github.com/Tencent/spring-cloud-tencent/wiki/Actuator-Endpoint-%E6%89%A9%E5%B1%95) - -- 最佳实践 - - [可观测性实践](https://github.com/Tencent/spring-cloud-tencent/wiki/可观测性实践) - - [测试环境路由](https://github.com/Tencent/spring-cloud-tencent/wiki/%E6%B5%8B%E8%AF%95%E7%8E%AF%E5%A2%83%E8%B7%AF%E7%94%B1) - - [Spring Cloud Gateway 流量染色](https://github.com/Tencent/spring-cloud-tencent/wiki/Spring-Cloud-Gateway-%E6%B5%81%E9%87%8F%E6%9F%93%E8%89%B2) - - [多注册与多发现](https://github.com/Tencent/spring-cloud-tencent/wiki/Multi-registration-and-multi-discovery) - -- 开发文档 - - [项目概览](https://github.com/Tencent/spring-cloud-tencent/wiki/%E9%A1%B9%E7%9B%AE%E6%A6%82%E8%A7%88) - - [参与共建](https://github.com/Tencent/spring-cloud-tencent/wiki/%E5%8F%82%E4%B8%8E%E5%85%B1%E5%BB%BA) +请阅读 [Wiki](https://github.com/Tencent/spring-cloud-tencent/wiki) ## 交流群 diff --git a/README.md b/README.md index 8d947f06..6d545bb5 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ [![Contributors](https://img.shields.io/github/contributors/Tencent/spring-cloud-tencent)](https://github.com/Tencent/spring-cloud-tencent/graphs/contributors) [![License](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](https://opensource.org/licenses/BSD-3-Clause) -[![Build Status](https://github.com/Tencent/spring-cloud-tencent/actions/workflows/junit_test.yml/badge.svg)](https://github.com/Tencent/spring-cloud-tencent/actions/workflows/junit_test.yml) +[![Test with Junit](https://github.com/Tencent/spring-cloud-tencent/actions/workflows/junit_test.yml/badge.svg)](https://github.com/Tencent/spring-cloud-tencent/actions/workflows/junit_test.yml) [![codecov.io](https://codecov.io/gh/Tencent/spring-cloud-tencent/branch/hoxton/graph/badge.svg)](https://codecov.io/gh/Tencent/spring-cloud-tencent?branch=hoxton) English | [简体中文](./README-zh.md) @@ -19,10 +19,10 @@ Spring Cloud Tencent implements the Spring Cloud standard microservice SPI, so d Cloud cloud-native distributed applications based on Spring Cloud Tencent. The core of Spring Cloud Tencent relies on Tencent's open-source one-stop service discovery and governance -platform [Polaris](https://github.com/polarismesh/polaris) to realize various distributed microservice scenarios. +platform [PolarisMesh](https://polarismesh.cn) to realize various distributed microservice scenarios. -- [Polaris Github home page](https://github.com/polarismesh/polaris) -- [Polaris official website](https://polarismesh.cn/) +- [PolarisMesh Github home page](https://github.com/polarismesh/polaris) +- [PolarisMesh official website](https://polarismesh.cn/) The capabilities provided by Spring Cloud Tencent include but are not limited to: @@ -59,6 +59,8 @@ dependencies. > Notice: > +> Support Spring Cloud 2022.0, 2021.0, 2020.0, Hoxton. +> > The version list of Spring Cloud Tencent can be found > in > [Spring Cloud Tencent Version Management](https://github.com/Tencent/spring-cloud-tencent/wiki/Spring-Cloud-Tencent-%E7%89%88%E6%9C%AC%E7%AE%A1%E7%90%86) @@ -74,7 +76,7 @@ For example: com.tencent.cloud spring-cloud-tencent-dependencies - 1.9.0-Hoxton.SR12 + 1.9.1-Hoxton.SR12 pom import @@ -105,27 +107,7 @@ You can build this project with command: ## Documents -- Usage Doc - - [Spring Cloud Tencent Version Management](https://github.com/Tencent/spring-cloud-tencent/wiki/Spring-Cloud-Tencent-%E7%89%88%E6%9C%AC%E7%AE%A1%E7%90%86) - - [Spring Cloud Tencent Discovery](https://github.com/Tencent/spring-cloud-tencent/wiki/Spring-Cloud-Tencent-Discovery-%E4%BD%BF%E7%94%A8%E6%96%87%E6%A1%A3) - - [Spring Cloud Tencent Config](https://github.com/Tencent/spring-cloud-tencent/wiki/Spring-Cloud-Tencent-Config-%E4%BD%BF%E7%94%A8%E6%96%87%E6%A1%A3) - - [Spring Cloud Tencent Rate Limit](https://github.com/Tencent/spring-cloud-tencent/wiki/Spring-Cloud-Tencent-Rate-Limit-%E4%BD%BF%E7%94%A8%E6%96%87%E6%A1%A3) - - [Spring Cloud Tencent CircuitBreaker](https://github.com/Tencent/spring-cloud-tencent/wiki/Spring-Cloud-Tencent-Circuitbreaker-%E4%BD%BF%E7%94%A8%E6%96%87%E6%A1%A3) - - [Spring Cloud Tencent Router](https://github.com/Tencent/spring-cloud-tencent/wiki/Spring-Cloud-Tencent-Router-%E4%BD%BF%E7%94%A8%E6%96%87%E6%A1%A3) - - [Spring Cloud Starter Tencent RPC Enhancement](https://github.com/Tencent/spring-cloud-tencent/wiki/RPC%E5%A2%9E%E5%BC%BA) - - [Spring Cloud Tencent Metadata Transfer](https://github.com/Tencent/spring-cloud-tencent/wiki/Spring-Cloud-Tencent-Metadata-Transfer-%E4%BD%BF%E7%94%A8%E6%8C%87%E5%8D%97) - - [Spring Cloud Tencent Plugins](https://github.com/Tencent/spring-cloud-tencent/wiki/%E5%9C%BA%E6%99%AF%E5%8C%96%E6%8F%92%E4%BB%B6) - - [Actuator Endpoint Extension](https://github.com/Tencent/spring-cloud-tencent/wiki/Actuator-Endpoint-%E6%89%A9%E5%B1%95) - -- Best Practices - - [Observability Practice](https://github.com/Tencent/spring-cloud-tencent/wiki/%E5%8F%AF%E8%A7%82%E6%B5%8B%E6%80%A7%E5%AE%9E%E8%B7%B5) - - [Multi-feature environment](https://github.com/Tencent/spring-cloud-tencent/wiki/%E5%A4%9A%E7%89%B9%E6%80%A7%E7%8E%AF%E5%A2%83) - - [Spring Cloud Gateway Traffic Staining](https://github.com/Tencent/spring-cloud-tencent/wiki/Spring-Cloud-Gateway-%E6%B5%81%E9%87%8F%E6%9F%93%E8%89%B2) - - [Multi-registration and multi-discovery](https://github.com/Tencent/spring-cloud-tencent/wiki/Multi-registration-and-multi-discovery) - -- Development documentation - - [Project Structure Overview](https://github.com/Tencent/spring-cloud-tencent/wiki/%E9%A1%B9%E7%9B%AE%E6%A6%82%E8%A7%88) - - [Participate in co-construction](https://github.com/Tencent/spring-cloud-tencent/wiki/%E5%8F%82%E4%B8%8E%E5%85%B1%E5%BB%BA) +Pelease refer to [Wiki](https://github.com/Tencent/spring-cloud-tencent/wiki) ## Chat Group diff --git a/pom.xml b/pom.xml index bc61ce23..9ee70db2 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.springframework.cloud spring-cloud-build - 2.3.5.RELEASE + 3.0.5 4.0.0 @@ -16,7 +16,7 @@ ${revision} Spring Cloud Tencent Spring Cloud Tencent - https://github.com/Tencent/spring-cloud-tencent/tree/hoxton + https://github.com/Tencent/spring-cloud-tencent/tree/2020.0 Tencent @@ -26,7 +26,7 @@ The BSD 3-Clause License (BSD3) - https://raw.githubusercontent.com/Tencent/spring-cloud-tencent/hoxton/LICENSE + https://raw.githubusercontent.com/Tencent/spring-cloud-tencent/2020.0/LICENSE repo @@ -205,6 +205,7 @@ 1 false + ${argLine} @@ -292,17 +293,6 @@ - - - - nexus-snapshots - https://oss.sonatype.org/content/repositories/snapshots/ - - - nexus-releases - https://oss.sonatype.org/service/local/staging/deploy/maven2/ - - sonatype @@ -331,4 +321,15 @@ + + + + nexus-snapshots + https://oss.sonatype.org/content/repositories/snapshots/ + + + nexus-releases + https://oss.sonatype.org/service/local/staging/deploy/maven2/ + + diff --git a/spring-cloud-starter-tencent-polaris-config/src/main/java/com/tencent/cloud/polaris/config/PolarisConfigAutoConfiguration.java b/spring-cloud-starter-tencent-polaris-config/src/main/java/com/tencent/cloud/polaris/config/PolarisConfigAutoConfiguration.java index aa319843..f336be29 100644 --- a/spring-cloud-starter-tencent-polaris-config/src/main/java/com/tencent/cloud/polaris/config/PolarisConfigAutoConfiguration.java +++ b/spring-cloud-starter-tencent-polaris-config/src/main/java/com/tencent/cloud/polaris/config/PolarisConfigAutoConfiguration.java @@ -39,6 +39,7 @@ import org.springframework.cloud.context.properties.ConfigurationPropertiesRebin import org.springframework.cloud.context.refresh.ContextRefresher; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Primary; /** * polaris config module auto configuration at init application context phase. @@ -60,7 +61,7 @@ public class PolarisConfigAutoConfiguration { } @Bean - @ConditionalOnMissingBean(search = SearchStrategy.CURRENT) + @Primary @ConditionalOnReflectRefreshType public ConfigurationPropertiesRebinder affectedConfigurationPropertiesRebinder( ConfigurationPropertiesBeans beans) { diff --git a/spring-cloud-starter-tencent-polaris-config/src/test/java/com/tencent/cloud/polaris/config/spring/annotation/SpringValueProcessorTest.java b/spring-cloud-starter-tencent-polaris-config/src/test/java/com/tencent/cloud/polaris/config/spring/annotation/SpringValueProcessorTest.java index 043278fe..d4d30c2f 100644 --- a/spring-cloud-starter-tencent-polaris-config/src/test/java/com/tencent/cloud/polaris/config/spring/annotation/SpringValueProcessorTest.java +++ b/spring-cloud-starter-tencent-polaris-config/src/test/java/com/tencent/cloud/polaris/config/spring/annotation/SpringValueProcessorTest.java @@ -81,6 +81,7 @@ public class SpringValueProcessorTest { .withConfiguration(AutoConfigurations.of(RefreshAutoConfiguration.class)) .withConfiguration(AutoConfigurations.of(ValueTest.class)) .withConfiguration(AutoConfigurations.of(PolarisConfigAutoConfiguration.class)) + .withAllowBeanDefinitionOverriding(true) .withPropertyValues("spring.application.name=" + "conditionalOnConfigReflectEnabledTest") .withPropertyValues("spring.cloud.polaris.address=grpc://127.0.0.1:10081") .withPropertyValues("spring.cloud.polaris.config.refresh-type=" + RefreshType.REFLECT) @@ -114,6 +115,7 @@ public class SpringValueProcessorTest { .withConfiguration(AutoConfigurations.of(RefreshAutoConfiguration.class)) .withConfiguration(AutoConfigurations.of(ValueTest.class)) .withConfiguration(AutoConfigurations.of(PolarisConfigAutoConfiguration.class)) + .withAllowBeanDefinitionOverriding(true) .withPropertyValues("spring.application.name=" + "conditionalOnConfigReflectEnabledTest") .withPropertyValues("spring.cloud.polaris.address=grpc://127.0.0.1:10081") .withPropertyValues("spring.cloud.polaris.config.refresh-type=" + RefreshType.REFLECT) @@ -147,6 +149,7 @@ public class SpringValueProcessorTest { .withConfiguration(AutoConfigurations.of(RefreshAutoConfiguration.class)) .withConfiguration(AutoConfigurations.of(XMLBeamDefinitionTest.class)) .withConfiguration(AutoConfigurations.of(PolarisConfigAutoConfiguration.class)) + .withAllowBeanDefinitionOverriding(true) .withPropertyValues("spring.application.name=" + "conditionalOnConfigReflectEnabledTest") .withPropertyValues("spring.cloud.polaris.address=grpc://127.0.0.1:10081") .withPropertyValues("spring.cloud.polaris.config.refresh-type=" + RefreshType.REFLECT) diff --git a/spring-cloud-tencent-commons/pom.xml b/spring-cloud-tencent-commons/pom.xml index 8ae161f1..db94e516 100644 --- a/spring-cloud-tencent-commons/pom.xml +++ b/spring-cloud-tencent-commons/pom.xml @@ -106,6 +106,12 @@ true + + com.tencent.polaris + polaris-test-common + test + + uk.org.webcompere system-stubs-jupiter diff --git a/spring-cloud-tencent-commons/src/test/java/com/tencent/cloud/common/pojo/PolarisServiceInstanceTest.java b/spring-cloud-tencent-commons/src/test/java/com/tencent/cloud/common/pojo/PolarisServiceInstanceTest.java new file mode 100644 index 00000000..afa2eec2 --- /dev/null +++ b/spring-cloud-tencent-commons/src/test/java/com/tencent/cloud/common/pojo/PolarisServiceInstanceTest.java @@ -0,0 +1,63 @@ +/* + * Tencent is pleased to support the open source community by making Spring Cloud Tencent available. + * + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * + * Licensed under the BSD 3-Clause License (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://opensource.org/licenses/BSD-3-Clause + * + * Unless required by applicable law or agreed to in writing, software distributed + * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR + * CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.tencent.cloud.common.pojo; + +import com.tencent.polaris.api.pojo.Instance; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +import static com.tencent.polaris.test.common.Consts.SERVICE_PROVIDER; +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.mock; + +/** + * Test for {@link PolarisServiceInstance}. + * + * @author Haotian Zhang + */ +@ExtendWith(MockitoExtension.class) +public class PolarisServiceInstanceTest { + + @Test + @DisplayName("test getters and setters.") + void test() { + Instance secureInstance = mock(Instance.class); + doReturn("test-ID").when(secureInstance).getId(); + doReturn(SERVICE_PROVIDER).when(secureInstance).getService(); + doReturn("1.1.1.1").when(secureInstance).getHost(); + doReturn(8080).when(secureInstance).getPort(); + doReturn("https").when(secureInstance).getProtocol(); + + PolarisServiceInstance securePolarisServiceInstance = new PolarisServiceInstance(secureInstance); + assertThat(securePolarisServiceInstance.getInstanceId()).isEqualTo("test-ID"); + assertThat(securePolarisServiceInstance.getServiceId()).isEqualTo(SERVICE_PROVIDER); + assertThat(securePolarisServiceInstance.getHost()).isEqualTo("1.1.1.1"); + assertThat(securePolarisServiceInstance.getPort()).isEqualTo(8080); + assertThat(securePolarisServiceInstance.isSecure()).isTrue(); + assertThat(securePolarisServiceInstance.getScheme()).isEqualTo("https"); + + Instance insecureInstance = mock(Instance.class); + doReturn("http").when(insecureInstance).getProtocol(); + PolarisServiceInstance insecurePolarisServiceInstance = new PolarisServiceInstance(insecureInstance); + assertThat(insecurePolarisServiceInstance.isSecure()).isFalse(); + assertThat(insecurePolarisServiceInstance.getScheme()).isEqualTo("http"); + } +} diff --git a/spring-cloud-tencent-dependencies/pom.xml b/spring-cloud-tencent-dependencies/pom.xml index 0eb9d26a..628bf468 100644 --- a/spring-cloud-tencent-dependencies/pom.xml +++ b/spring-cloud-tencent-dependencies/pom.xml @@ -357,17 +357,17 @@ - - - - nexus-snapshots - https://oss.sonatype.org/content/repositories/snapshots/ - - - nexus-releases - https://oss.sonatype.org/service/local/staging/deploy/maven2/ - - + + + + nexus-snapshots + https://oss.sonatype.org/content/repositories/snapshots/ + + + nexus-releases + https://oss.sonatype.org/service/local/staging/deploy/maven2/ + +