【发布时间】:2013-07-01 17:38:35
【问题描述】:
我的问题与此问题完全相同: Spring application context external properties?
这就是我之前注入 props 文件的方式:
<util:properties id="smrProps" location="classpath:/spring/SomeProps.properties" />
但是对于我的生活,当我想注入一个与可运行 jar 位于同一目录中的属性文件时,我无法弄清楚在 location 中使用什么。我知道类路径指向的位置,并且我的道具只是上一级,所以我什至尝试了classpath:/../SomeProps.properties,假设它会在父文件夹中查找,但没有运气。
例如,如果 jar 位于:C:\temp\some.jarand 属性文件位于 C:\temp\SomeProps.properties 中
如果 some.jar 在 temp 中,那么 SomeProps.properties 也将在 temp 中。当然,我不能在 location 中使用 C:\temp\SomeProps.properties
有人可以指导我如何使用这个道具文件吗?
【问题讨论】:
-
如果您使用的是 Spring Boot,您可以查看docs.spring.io/spring-boot/docs/current/reference/html/…
标签: java spring properties jar