• 8. Spring 使用外部属性文件 注解


    8.1 主要清单 @PropertySource 和 Environment

    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.context.annotation.Bean;
    import org.springframework.context.annotation.Configuration;
    import org.springframework.context.annotation.PropertySource;
    import org.springframework.core.env.Environment;
    
    @Configuration
    @PropertySource("classpath:/app.properties")
    public class ExpressiveConfig {
        @Autowired
        private Environment environment;
    
        @Bean
        public A a(){
            new A(environment.getProperty("a.name"));
        }
    }
  • 相关阅读:
    Intern Day5
    PTA1007
    Intern Day5
    Intern Day2
    Intern Day5
    Intern Day2
    Intern Day2
    Intern Day2
    Intern Day1
    柯南剧场版17绝海的侦探
  • 原文地址:https://www.cnblogs.com/black-/p/9072121.html
Copyright © 2020-2023  润新知