通过类路径Spring访问war tomcat中依赖jar中的属性文件



让A成为我基于jar maven的核心项目类。在另一个项目中,W是我的战争。我已经添加了A作为我对W的依赖。我已经将prop.properties文件存储在资源文件夹中的A中。在我的war中,如何使用classpath从jar访问属性文件。使用弹簧4。我已经用以下内容更新了jar的spring.xml:

 <context:property-placeholder 
 location="classpath:prop.properties" ignore-unresolvable="true"/>

classpath之后使用Asterisk,这将告诉spring在类路径中所有添加的依赖项中查找配置:

<context:property-placeholder 
 location="classpath*:prop.properties" ignore-unresolvable="true"/>

最新更新