package com.restfiddle.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.context.annotation.PropertySource;
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
/**
* Created by santoshm1 on 04/06/14.
*
* Adds support for runtime property files. Run with -Dspring.profiles.active={production,default,development,test} defaults to development.
*
*/
@Configuration
@PropertySource(value={"classpath:common.properties"})
public class PropertyConfig {
public PropertyConfig() {}
@Bean
public static PropertySourcesPlaceholderConfigurer myPropertySourcesPlaceholderConfigurer() {
return new PropertySourcesPlaceholderConfigurer();
}
/**
* Properties to support the 'production' mode of operation.
*/
@Configuration
@Profile("production")
@PropertySource(value={"classpath:env-production.properties"})
static class Production {
// Define additional beans for this profile here
}
/**
* Properties to support the 'test' mode of operation.
*/
@Configuration
@Profile({ "devlopment", "default" })
@PropertySource(value={"classpath:env-development.properties"})
static class Dev {
}
/**
* Properties to support the 'test' mode of operation.
*/
@Configuration
@Profile("test")
@PropertySource(value={"classpath:env-test.properties"})
static class Test {
}
}
《Springboot极简教程》SpringBoot配置文件PropertySourcesPlaceholderConfigurer
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
推荐阅读更多精彩内容
- APPLICATION FAILED TO START Description: Parameter 0 of c...
- 首先,这个出错页面是SpringBoot的一个默认出错页面。源码在:org.springframework.boo...
- https://blog.csdn.net/forezp/article/details/70341818本文出自...
- RESTFeel RESTFeel: 一个企业级的API管理&测试平台。RESTFeel帮助你设计、开发、测试您的...
- http://docs.spring.io/spring-boot/docs/current/reference/...