如何解决春天的外部属性文件
朋友
我有一个带有maven的java,spring而不是spring boot命令行程序,当我使用maven-assembly-plugin构建一个具有所有依赖关系的jar时,它包含application.properties,我需要知道的是如何阅读外部application.properties而不是jar之一。
我正在读取属性文件为:
@override
Widget build(BuildContext context) {
return Stack(
alignment: Alignment.center,children: <Widget>[
GestureDetector(
onPanDown: (details) {
print("father");
},child: Container(
alignment: Alignment.center,color: Colors.red,width: 300,height: 300,),GestureDetector(
onPanDown: (details) {
print("child");
},color: Colors.blue,width: 100,height: 100,child: Text("data"),],);
}
如果我打印类路径,则类路径仅包含jar,而不包括当前目录。
有人可以帮忙吗?
谢谢 阿比
解决方法
这是您可以做的:
student(2000100001,1,[math101,phys201,ec201]).
student(2000100002,hist301]).
student(2000100003,[physics201,ec201,hist301])
此list_students(math101,L).
L = [2000100001,2000100002]
自4.3春季起可用,非常不言自明。
您也可以选择“程序化”方法。在纯弹簧中(不是您在问题中提到的弹簧靴):
@PropertySources({
@PropertySource("classpath:application.properties"),@PropertySource(value = "file:/etc/config/my-custom-config.properties",ignoreResourceNotFound = true)
})
ignoreResourceNotFound
用于访问文件系统中外部可用的资源
@Configuration
public class CommonConfig {
...
@Bean
public static PropertySourcesPlaceholderConfigurer propertyPlaceholderConfigurer() {
PropertySourcesPlaceholderConfigurer ppc = new PropertySourcesPlaceholderConfigurer();
ppc.setLocations(new FileSystemResource("/etc/config/my-custom-config.properties"),new ClassPathResource("config/application.properties"),return ppc;
}
...
}
用于访问类路径中的资源
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。