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

标签 java spring maven tomcat

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

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

最佳答案

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

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

关于java - 通过类路径 Spring 访问 war tomcat 中依赖项 jar 中的属性文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38739690/

相关文章:

java - JBPM 3.2.3 示例项目与 MAVEN 的集成

java - Jenkins hpi 插件有太多的 jar 文件

java - 在 Java AWT 框架上托管 ActiveX 控件?

java - Spring Security 初始化在 mvcContentNegotiationManager 上抛出 UnsatisfiedDependencyException

java - Websocket 示例将不起作用

java - 如何获取 Spring Batch Job 后的失败次数?

SpringRestDoc SnippetException : Fields with the following paths were not found in the payload:

java - 请求作用域 bean 不会调用 @PreDestroy 方法

java - 使用 JsonPath 在不知道键的情况下提取值

java - Web 应用程序和独立 Java 应用程序的不同依赖范围