mirror of
https://gitee.com/mirrors/Spring-Cloud-Alibaba.git
synced 2021-06-26 13:25:11 +08:00
Merge branch 'master' of https://github.com/yuhuangbin/spring-cloud-alibaba
This commit is contained in:
commit
432f3e3e05
@ -71,7 +71,7 @@ These artifacts are available from Maven Central and Spring Release repository v
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.alibaba.cloud</groupId>
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
|
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
|
||||||
<version>2.2.0.RELEASE</version>
|
<version>2.2.1.RELEASE</version>
|
||||||
<type>pom</type>
|
<type>pom</type>
|
||||||
<scope>import</scope>
|
<scope>import</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
51
pom.xml
51
pom.xml
@ -349,6 +349,31 @@
|
|||||||
<reuseForks>false</reuseForks>
|
<reuseForks>false</reuseForks>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
|
<artifactId>flatten-maven-plugin</artifactId>
|
||||||
|
<version>${flatten-maven-plugin.version}</version>
|
||||||
|
<configuration>
|
||||||
|
<updatePomFile>true</updatePomFile>
|
||||||
|
<flattenMode>resolveCiFriendliesOnly</flattenMode>
|
||||||
|
</configuration>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>flatten</id>
|
||||||
|
<phase>process-resources</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>flatten</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
<execution>
|
||||||
|
<id>flatten.clean</id>
|
||||||
|
<phase>clean</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>clean</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
@ -406,32 +431,6 @@
|
|||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.codehaus.mojo</groupId>
|
|
||||||
<artifactId>flatten-maven-plugin</artifactId>
|
|
||||||
<version>${flatten-maven-plugin.version}</version>
|
|
||||||
<configuration>
|
|
||||||
<updatePomFile>true</updatePomFile>
|
|
||||||
<flattenMode>resolveCiFriendliesOnly</flattenMode>
|
|
||||||
</configuration>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<id>flatten</id>
|
|
||||||
<phase>process-resources</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>flatten</goal>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
<execution>
|
|
||||||
<id>flatten.clean</id>
|
|
||||||
<phase>clean</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>clean</goal>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
<revision>2.2.1.RELEASE</revision>
|
<revision>2.2.1.RELEASE</revision>
|
||||||
<sentinel.version>1.7.1</sentinel.version>
|
<sentinel.version>1.7.1</sentinel.version>
|
||||||
<oss.version>3.1.0</oss.version>
|
<oss.version>3.1.0</oss.version>
|
||||||
<seata.version>1.1.0</seata.version>
|
<seata.version>1.2.0</seata.version>
|
||||||
<nacos.client.version>1.2.1</nacos.client.version>
|
<nacos.client.version>1.2.1</nacos.client.version>
|
||||||
<nacos.config.version>0.8.0</nacos.config.version>
|
<nacos.config.version>0.8.0</nacos.config.version>
|
||||||
<spring.context.support.version>1.0.6</spring.context.support.version>
|
<spring.context.support.version>1.0.6</spring.context.support.version>
|
||||||
|
@ -175,7 +175,7 @@ AccessKey|spring.cloud.nacos.config.access-key||
|
|||||||
SecretKey|spring.cloud.nacos.config.secret-key||
|
SecretKey|spring.cloud.nacos.config.secret-key||
|
||||||
相对路径|spring.cloud.nacos.config.context-path||服务端 API 的相对路径
|
相对路径|spring.cloud.nacos.config.context-path||服务端 API 的相对路径
|
||||||
接入点|spring.cloud.nacos.config.endpoint|UTF-8|地域的某个服务的入口域名,通过此域名可以动态地拿到服务端地址
|
接入点|spring.cloud.nacos.config.endpoint|UTF-8|地域的某个服务的入口域名,通过此域名可以动态地拿到服务端地址
|
||||||
是否开启监听和自动刷新|spring.cloud.nacos.config.refresh.enabled|true|
|
是否开启监听和自动刷新|spring.cloud.nacos.config.refresh-enabled|true|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -76,12 +76,17 @@ public class DubboServiceRegistrationNonWebApplicationAutoConfiguration {
|
|||||||
|
|
||||||
@Around("execution(* org.springframework.cloud.client.serviceregistry.Registration.getPort())")
|
@Around("execution(* org.springframework.cloud.client.serviceregistry.Registration.getPort())")
|
||||||
public Object getPort(ProceedingJoinPoint pjp) throws Throwable {
|
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 <a href="mailto:chenxilzx1@gmail.com">theonefx</a>
|
||||||
|
*/
|
||||||
|
setServerPort();
|
||||||
return serverPort != null ? serverPort : pjp.proceed();
|
return serverPort != null ? serverPort : pjp.proceed();
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventListener(ApplicationStartedEvent.class)
|
@EventListener(ApplicationStartedEvent.class)
|
||||||
public void onApplicationStarted() {
|
public void onApplicationStarted() {
|
||||||
setServerPort();
|
|
||||||
register();
|
register();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -99,18 +104,22 @@ public class DubboServiceRegistrationNonWebApplicationAutoConfiguration {
|
|||||||
*/
|
*/
|
||||||
private void setServerPort() {
|
private void setServerPort() {
|
||||||
if (serverPort == null) {
|
if (serverPort == null) {
|
||||||
for (List<URL> urls : repository.getAllExportedUrls().values()) {
|
synchronized (DubboServiceRegistrationNonWebApplicationAutoConfiguration.class) {
|
||||||
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) {
|
if (serverPort == null) {
|
||||||
urls.stream().findAny().ifPresent(url -> {
|
for (List<URL> urls : repository.getAllExportedUrls().values()) {
|
||||||
serverPort = url.getPort();
|
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)
|
@EventListener(ServiceInstancePreRegisteredEvent.class)
|
||||||
public void onServiceInstancePreRegistered(
|
public void onServiceInstancePreRegistered(
|
||||||
ServiceInstancePreRegisteredEvent event) {
|
ServiceInstancePreRegisteredEvent event) {
|
||||||
|
setServerPort();
|
||||||
registration.setPort(serverPort);
|
registration.setPort(serverPort);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user