我們都知道在使用Spring的時候,如果要讀取本項目classpath下的.properties文件時,可以通過下面的方式讀取相應(yīng)的鍵值:@Configuration@PropertySource("classpath:/application.properties")public class AppConfig { @Value("${app.name}") public String name; @Bean
public static PropertySourcesPlaceholderConfigurer placeholderConfigurer() { return new PropertySourcesPlaceholderConfigurer();
}
@Bean
public PostService postService() { return new PostServiceImpl(name);
}
}但是如果我使用Spring寫一個框架,而依賴該框架的客戶項目中需要配置某些參數(shù),框架需要讀取該客戶項目中的.properties該如何獲???
添加回答
舉報
0/150
提交
取消