Spring cloud 是否使用配置文件禁用Spring云服务器配置?
我希望实现以下目标:Spring cloud 是否使用配置文件禁用Spring云服务器配置?,spring-cloud,Spring Cloud,我希望实现以下目标: 在“dev”模式下,在当前webapp中embbed Spring Cloud配置 当不处于“dev”模式时,连接到已经运行的Spring Cloud Config服务器实例 因此,当前webapp的类路径包含对配置服务器和客户端的依赖项: 当不处于“dev”模式(例如spring.profiles.active=prod)时,当前的webapp不会启动:它无法自动连接我的属性(我猜嵌入式服务器是在错误配置下启动的) 如果我在POM中注释SpringCloudConfi
- 在“dev”模式下,在当前webapp中embbed Spring Cloud配置
- 当不处于“dev”模式时,连接到已经运行的Spring Cloud Config服务器实例
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-parent</artifactId>
<version>1.0.3.BUILD-SNAPSHOT</version>
</parent>
因此,它无法连接到配置服务器模块。如果您在客户端应用程序模块中注释maven dependencies:spring cloud config server,它会再次工作
希望现在更清楚。
谢谢,根据in-spring cloud config server:config server显式禁用配置客户端,除非您从系统属性(
-D
)或通过SpringApplicationBuilder
设置spring.cloud.config.enabled=true
。这是目前唯一能让它工作的方法。欢迎您提交一个增强请求来解释您的用例。我原以为@Profile(“dev”)
会起作用。你看到的错误是什么?我刚刚编辑了我的帖子,让它更清楚。谢谢。我确实在bootstrap.yml(用于profile!dev)中看到并尝试设置此属性,但没有成功。我刚刚试着从系统属性(-D
)设置它,它可以正常工作。谢谢另外,使用SpringApplicationBuilder
似乎不起作用。。。
spring:
application:
name: app1
profiles:
active: dev
cloud:
config:
uri: ${SPRING_CONFIG_URI:http://localhost:8888}
---
spring:
profiles: dev
cloud:
config:
server:
bootstrap: true
git:
uri: https://github.com/nocquidant/my-config-repo.git
basedir: target/config
@Configuration
@Profile("dev")
@EnableConfigServer
public static class EmbeddedConfigServer { }
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-parent</artifactId>
<version>1.0.3.BUILD-SNAPSHOT</version>
</parent>
Caused by: org.springframework.validation.BindException: org.springframework.validation.BeanPropertyBindingResult: 1 errors
Field error in object 'server' on field 'port': rejected value [${taap.bak.config.port}];