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服务器实例
因此,当前webapp的类路径包含对配置服务器和客户端的依赖项:

当不处于“dev”模式(例如spring.profiles.active=prod)时,当前的webapp不会启动:它无法自动连接我的属性(我猜嵌入式服务器是在错误配置下启动的)

如果我在POM中注释SpringCloudConfig服务器依赖项,那么它就可以工作

我认为我可以通过以下方法实现我想要的,但是没有(实际上使用EnableConfigServer与否似乎不会改变任何事情):

我该怎么做(不使用maven profile)? 有没有一种简单的方法来禁用SpringCloudConfigServer? 有没有更好的方法来实现我的目标

谢谢你的帮助

使用的p.S.版本:

<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}];