diff --git a/README.md b/README.md index 9a6de05a7..f2453c759 100644 --- a/README.md +++ b/README.md @@ -71,7 +71,7 @@ These artifacts are available from Maven Central and Spring Release repository v com.alibaba.cloud spring-cloud-alibaba-dependencies - 2.2.0.RELEASE + 2.2.1.RELEASE pom import diff --git a/pom.xml b/pom.xml index 086299151..e96ed3544 100644 --- a/pom.xml +++ b/pom.xml @@ -349,6 +349,31 @@ false + + org.codehaus.mojo + flatten-maven-plugin + ${flatten-maven-plugin.version} + + true + resolveCiFriendliesOnly + + + + flatten + process-resources + + flatten + + + + flatten.clean + clean + + clean + + + + @@ -406,32 +431,6 @@ - - - org.codehaus.mojo - flatten-maven-plugin - ${flatten-maven-plugin.version} - - true - resolveCiFriendliesOnly - - - - flatten - process-resources - - flatten - - - - flatten.clean - clean - - clean - - - - diff --git a/spring-cloud-alibaba-dependencies/pom.xml b/spring-cloud-alibaba-dependencies/pom.xml index 251909469..599e75217 100644 --- a/spring-cloud-alibaba-dependencies/pom.xml +++ b/spring-cloud-alibaba-dependencies/pom.xml @@ -21,7 +21,7 @@ 2.2.1.RELEASE 1.7.1 3.1.0 - 1.1.0 + 1.2.0 1.2.1 0.8.0 1.0.6 diff --git a/spring-cloud-alibaba-examples/nacos-example/nacos-config-example/readme-zh.md b/spring-cloud-alibaba-examples/nacos-example/nacos-config-example/readme-zh.md index 2c9441f38..c58f67833 100644 --- a/spring-cloud-alibaba-examples/nacos-example/nacos-config-example/readme-zh.md +++ b/spring-cloud-alibaba-examples/nacos-example/nacos-config-example/readme-zh.md @@ -175,7 +175,7 @@ AccessKey|spring.cloud.nacos.config.access-key|| SecretKey|spring.cloud.nacos.config.secret-key|| 相对路径|spring.cloud.nacos.config.context-path||服务端 API 的相对路径 接入点|spring.cloud.nacos.config.endpoint|UTF-8|地域的某个服务的入口域名,通过此域名可以动态地拿到服务端地址 -是否开启监听和自动刷新|spring.cloud.nacos.config.refresh.enabled|true| +是否开启监听和自动刷新|spring.cloud.nacos.config.refresh-enabled|true| diff --git a/spring-cloud-alibaba-starters/spring-cloud-starter-dubbo/src/main/java/com/alibaba/cloud/dubbo/autoconfigure/DubboServiceRegistrationNonWebApplicationAutoConfiguration.java b/spring-cloud-alibaba-starters/spring-cloud-starter-dubbo/src/main/java/com/alibaba/cloud/dubbo/autoconfigure/DubboServiceRegistrationNonWebApplicationAutoConfiguration.java index a9b8c33de..414e7a0ab 100644 --- a/spring-cloud-alibaba-starters/spring-cloud-starter-dubbo/src/main/java/com/alibaba/cloud/dubbo/autoconfigure/DubboServiceRegistrationNonWebApplicationAutoConfiguration.java +++ b/spring-cloud-alibaba-starters/spring-cloud-starter-dubbo/src/main/java/com/alibaba/cloud/dubbo/autoconfigure/DubboServiceRegistrationNonWebApplicationAutoConfiguration.java @@ -76,12 +76,17 @@ public class DubboServiceRegistrationNonWebApplicationAutoConfiguration { @Around("execution(* org.springframework.cloud.client.serviceregistry.Registration.getPort())") public Object getPort(ProceedingJoinPoint pjp) throws Throwable { + /** + * move setServerPort from onApplicationStarted() to here for this issue : + * https://github.com/alibaba/spring-cloud-alibaba/issues/1383 + * @author theonefx + */ + setServerPort(); return serverPort != null ? serverPort : pjp.proceed(); } @EventListener(ApplicationStartedEvent.class) public void onApplicationStarted() { - setServerPort(); register(); } @@ -99,18 +104,22 @@ public class DubboServiceRegistrationNonWebApplicationAutoConfiguration { */ private void setServerPort() { if (serverPort == null) { - for (List urls : repository.getAllExportedUrls().values()) { - urls.stream() - .filter(url -> REST_PROTOCOL.equalsIgnoreCase(url.getProtocol())) - .findFirst().ifPresent(url -> { - serverPort = url.getPort(); - }); - - // If REST protocol is not present, use any applied port. + synchronized (DubboServiceRegistrationNonWebApplicationAutoConfiguration.class) { if (serverPort == null) { - urls.stream().findAny().ifPresent(url -> { - serverPort = url.getPort(); - }); + for (List urls : repository.getAllExportedUrls().values()) { + urls.stream().filter( + url -> REST_PROTOCOL.equalsIgnoreCase(url.getProtocol())) + .findFirst().ifPresent(url -> { + serverPort = url.getPort(); + }); + + // If REST protocol is not present, use any applied port. + if (serverPort == null) { + urls.stream().findAny().ifPresent(url -> { + serverPort = url.getPort(); + }); + } + } } } } @@ -126,6 +135,7 @@ public class DubboServiceRegistrationNonWebApplicationAutoConfiguration { @EventListener(ServiceInstancePreRegisteredEvent.class) public void onServiceInstancePreRegistered( ServiceInstancePreRegisteredEvent event) { + setServerPort(); registration.setPort(serverPort); }