Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/388.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java spring云配置中的spring.profiles.include属性_Java_Spring_Spring Boot_Spring Cloud Config - Fatal编程技术网

Java spring云配置中的spring.profiles.include属性

Java spring云配置中的spring.profiles.include属性,java,spring,spring-boot,spring-cloud-config,Java,Spring,Spring Boot,Spring Cloud Config,我有一个spring启动应用程序。我正在使用spring.profiles.includein application.yml根据给定的配置文件添加一些活动配置文件,然后我使用这些活动配置文件创建bean,如下所示: application.yml: spring: profiles: prod profiles.include: - enable_tls - enable_mongo_ssl 配置类-根据活动配置文件创建bean: @Configuration @Pr

我有一个spring启动应用程序。我正在使用spring.profiles.includein application.yml根据给定的配置文件添加一些活动配置文件,然后我使用这些活动配置文件创建bean,如下所示:

application.yml:

spring:
  profiles: prod
  profiles.include:
    - enable_tls
    - enable_mongo_ssl
配置类-根据活动配置文件创建bean:

@Configuration
@PropertySource("classpath:/mongo-${mongo.environment}.properties")
public class MongoConfiguration {
    @Bean
    @Profile("enable_mongo_ssl")
    public MongoClientOptions.Builder mongoClientOptionsBuilder() {
        return getMongoClientOptionsBuilder();
    }
这个很好用。 但是,当我删除application.yml并通过SpringCloudConfig-with Git repository使用外部配置时,这不起作用。活动概要文件只是prod,不包括“enable_tls”和“enable_mongo_ssl”,因此在bean创建时,语句:

@Profile("enable_mongo_ssl")
这不再是事实

当我查询环境控制器时,我可以看到配置文件enable_tls和enable_mongo_ssl:

 "profiles": [
        "prod"
    ],
    "label": null,
    "version": "2ddd208fff7caa48b2ae41d69020325ce61f241e",
    "state": null,
    "propertySources": [
        {
            "name": "file:///C://dev/config-repo/config/application-prod.yml",
            "source": {
                "spring.profiles.include[0]": "enable_tls",
                "spring.profiles.include[1]": "enable_mongo_ssl",
                "server.ssl.key-store-password": "ENC(xxx)",
            }
        }
有限制吗?我们可以在外部配置中使用spring.profiles.include,而不是在本地application.yml文件中使用吗

有关信息,我正在使用Finchley.SR3版本


我当前的解决方案是将除spring.profiles.include之外的所有属性外部化到Config Server中,并保留在application.yml类路径文件中。

他们不想从服务器实现递归配置文件检索:


只需在bootstrap.yaml中列出您的所有功能标志(Spring配置文件)((

他们不想从服务器实现递归配置文件检索:


只需在bootstrap.yaml((

这是我在问题中描述的解决方法。这不是最好的解决方案,但它有效。谢谢。这是我在问题中描述的解决方法。不是最好的解决方案,但它有效。谢谢。