通过类路径Spring访问war Tomcat中的依赖项jar中的属性文件 [英] Access a properties file within a dependency jar in a war tomcat via classpath Spring

查看:81
本文介绍了通过类路径Spring访问war Tomcat中的依赖项jar中的属性文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Let A be my core jar maven based project class. And W be my war in another project. I have added A as my dependency to W. I have stored my prop.properties file in A in the resource folder. How do I access the properties file from the jar using classpath in my war. Using Spring 4. I have updated spring.xml for the jar with the following:

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

推荐答案

使用

Use Asterisk after classpath this will tell spring to look for configuration in all the added dependencies in your classpath:

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

这篇关于通过类路径Spring访问war Tomcat中的依赖项jar中的属性文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆