fix: NacosMetadataConfig添加@ConditionalOnBean避免Gateway加载失败
NacosMetadataConfig仅在Registration bean存在时生效, 解决Gateway等不需要服务注册的场景无法启动的问题
This commit is contained in:
parent
4af7d712cd
commit
a78ccaeae5
@ -1,4 +1,4 @@
|
|||||||
#NOTE: This is a Maven Resolver internal implementation file, its format can be changed without prior notice.
|
#NOTE: This is a Maven Resolver internal implementation file, its format can be changed without prior notice.
|
||||||
#Fri Feb 20 17:27:25 CST 2026
|
#Fri Feb 20 18:12:34 CST 2026
|
||||||
fund-common-0.0.1-SNAPSHOT.jar>=
|
fund-common-0.0.1-SNAPSHOT.jar>=
|
||||||
fund-common-0.0.1-SNAPSHOT.pom>=
|
fund-common-0.0.1-SNAPSHOT.pom>=
|
||||||
|
|||||||
Binary file not shown.
@ -3,7 +3,7 @@
|
|||||||
<groupId>com.fundplatform</groupId>
|
<groupId>com.fundplatform</groupId>
|
||||||
<artifactId>fund-common</artifactId>
|
<artifactId>fund-common</artifactId>
|
||||||
<versioning>
|
<versioning>
|
||||||
<lastUpdated>20260220092715</lastUpdated>
|
<lastUpdated>20260220101230</lastUpdated>
|
||||||
<snapshot>
|
<snapshot>
|
||||||
<localCopy>true</localCopy>
|
<localCopy>true</localCopy>
|
||||||
</snapshot>
|
</snapshot>
|
||||||
@ -11,12 +11,12 @@
|
|||||||
<snapshotVersion>
|
<snapshotVersion>
|
||||||
<extension>pom</extension>
|
<extension>pom</extension>
|
||||||
<value>0.0.1-SNAPSHOT</value>
|
<value>0.0.1-SNAPSHOT</value>
|
||||||
<updated>20260220092715</updated>
|
<updated>20260220101230</updated>
|
||||||
</snapshotVersion>
|
</snapshotVersion>
|
||||||
<snapshotVersion>
|
<snapshotVersion>
|
||||||
<extension>jar</extension>
|
<extension>jar</extension>
|
||||||
<value>0.0.1-SNAPSHOT</value>
|
<value>0.0.1-SNAPSHOT</value>
|
||||||
<updated>20260220092715</updated>
|
<updated>20260220101230</updated>
|
||||||
</snapshotVersion>
|
</snapshotVersion>
|
||||||
</snapshotVersions>
|
</snapshotVersions>
|
||||||
</versioning>
|
</versioning>
|
||||||
|
|||||||
@ -6,6 +6,6 @@
|
|||||||
<versions>
|
<versions>
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
</versions>
|
</versions>
|
||||||
<lastUpdated>20260220092715</lastUpdated>
|
<lastUpdated>20260220101230</lastUpdated>
|
||||||
</versioning>
|
</versioning>
|
||||||
</metadata>
|
</metadata>
|
||||||
|
|||||||
@ -1,3 +1,3 @@
|
|||||||
#NOTE: This is a Maven Resolver internal implementation file, its format can be changed without prior notice.
|
#NOTE: This is a Maven Resolver internal implementation file, its format can be changed without prior notice.
|
||||||
#Fri Feb 20 17:13:04 CST 2026
|
#Fri Feb 20 18:12:31 CST 2026
|
||||||
fundplatform-0.0.1-SNAPSHOT.pom>=
|
fundplatform-0.0.1-SNAPSHOT.pom>=
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
<groupId>com.fundplatform</groupId>
|
<groupId>com.fundplatform</groupId>
|
||||||
<artifactId>fundplatform</artifactId>
|
<artifactId>fundplatform</artifactId>
|
||||||
<versioning>
|
<versioning>
|
||||||
<lastUpdated>20260220091303</lastUpdated>
|
<lastUpdated>20260220101230</lastUpdated>
|
||||||
<snapshot>
|
<snapshot>
|
||||||
<localCopy>true</localCopy>
|
<localCopy>true</localCopy>
|
||||||
</snapshot>
|
</snapshot>
|
||||||
@ -11,7 +11,7 @@
|
|||||||
<snapshotVersion>
|
<snapshotVersion>
|
||||||
<extension>pom</extension>
|
<extension>pom</extension>
|
||||||
<value>0.0.1-SNAPSHOT</value>
|
<value>0.0.1-SNAPSHOT</value>
|
||||||
<updated>20260220091303</updated>
|
<updated>20260220101230</updated>
|
||||||
</snapshotVersion>
|
</snapshotVersion>
|
||||||
</snapshotVersions>
|
</snapshotVersions>
|
||||||
</versioning>
|
</versioning>
|
||||||
|
|||||||
@ -6,6 +6,6 @@
|
|||||||
<versions>
|
<versions>
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
</versions>
|
</versions>
|
||||||
<lastUpdated>20260220091303</lastUpdated>
|
<lastUpdated>20260220101230</lastUpdated>
|
||||||
</versioning>
|
</versioning>
|
||||||
</metadata>
|
</metadata>
|
||||||
|
|||||||
@ -2,7 +2,9 @@ package com.fundplatform.common.nacos;
|
|||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||||
import org.springframework.cloud.client.serviceregistry.Registration;
|
import org.springframework.cloud.client.serviceregistry.Registration;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
@ -29,8 +31,12 @@ import java.util.Map;
|
|||||||
* # 方式2: 配置文件
|
* # 方式2: 配置文件
|
||||||
* spring.cloud.nacos.discovery.metadata.tenant-id=VIP_001
|
* spring.cloud.nacos.discovery.metadata.tenant-id=VIP_001
|
||||||
* </pre>
|
* </pre>
|
||||||
|
*
|
||||||
|
* <p>注意:此配置仅在 Registration Bean 存在时生效(普通微服务),
|
||||||
|
* Gateway 等不需要服务注册的场景不会加载此类。</p>
|
||||||
*/
|
*/
|
||||||
@Configuration
|
@Configuration
|
||||||
|
@ConditionalOnBean(Registration.class)
|
||||||
@ConditionalOnProperty(name = "tenant.routing.enabled", havingValue = "true", matchIfMissing = true)
|
@ConditionalOnProperty(name = "tenant.routing.enabled", havingValue = "true", matchIfMissing = true)
|
||||||
public class NacosMetadataConfig {
|
public class NacosMetadataConfig {
|
||||||
|
|
||||||
@ -48,6 +54,7 @@ public class NacosMetadataConfig {
|
|||||||
|
|
||||||
private final Registration registration;
|
private final Registration registration;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
public NacosMetadataConfig(Registration registration) {
|
public NacosMetadataConfig(Registration registration) {
|
||||||
this.registration = registration;
|
this.registration = registration;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user