我的问题是这个问题的一个完全相同的副本: Spring application context external properties?如何注入的外部属性在Spring上下文文件
这是我如何注入道具之前文件:
<util:properties id="smrProps" location="classpath:/spring/SomeProps.properties" />
但对于生活我不知道在location
中使用什么时,我想注入一个属性文件,它将与可运行的jar文件位于同一个目录中。我知道classpath指向的地方,我的道具只有一层,所以我甚至试着假设classpath:/../SomeProps.properties
会在父文件夹中查找,但没有运气。
对于离如果罐子是:C:\temp\some.jar
和属性文件是C:\temp\SomeProps.properties
如果some.jar是在温度,然后SomeProps.properties也将在温度。当然,我不能在位置使用C:\ temp \ SomeProps.properties
有人能指导我如何使用这个道具文件吗?
如果您在使用Spring启动时,您可以校验H TTP://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-external-config.html – shobull