在spring上下文中通过类路径引用文件 [英] Referencing a file via classpath in spring context
问题描述
我正在尝试设置 org.springframework.beans.factory.config.PropertyPlaceholderConfigurer
spring bean,我在 src /中有jdbc.properties main / config
..当我把这个文件放在 src / main / resources
中并放入 classpath:
in value我的app成功部署。
I'm trying to set org.springframework.beans.factory.config.PropertyPlaceholderConfigurer
spring bean, I have jdbc.properties in src/main/config
.. when I put this file in src/main/resources
and put classpath:
in value my app deploys successfuly.
当jdbc.properties位于 src / main / resources $ c $时,这种方法有效c>
This works when jdbc.properties is located in src/main/resources
<property name="location" value="classpath:jdbc.properties" />
但是我需要在 src / main / config中放置任何配置
,如何以正确的方式将弹簧指向此位置?
However I'm required to put any configuration inside src/main/config
, how do I point springs towards this location in the right way?
推荐答案
这是一个类路径问题,而不是Spring问题。将src / main / config添加到类路径中,它将起作用。在Eclipse中,这意味着将它添加到项目Build Path-> Source。
This is a classpath issue, not a Spring issue. Add src/main/config to your classpath and it will work. In Eclipse, this means adding it to the project Build Path->Source.
这篇关于在spring上下文中通过类路径引用文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!