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")); } }