美文网首页程序员写作SpringBoot极简教程 · Spring Boot
《Springboot极简教程》SpringBoot配置文件Pr

《Springboot极简教程》SpringBoot配置文件Pr

作者: 光剑书架上的书 | 来源:发表于2017-03-23 22:42 被阅读23次
    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配置文件Pr

        本文链接:https://www.haomeiwen.com/subject/gcxxottx.html