Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring 从jar文件读取maven ear/ejb的pom.xml属性,jar文件是maven依赖项的一部分_Spring_Maven_Maven Plugin - Fatal编程技术网

Spring 从jar文件读取maven ear/ejb的pom.xml属性,jar文件是maven依赖项的一部分

Spring 从jar文件读取maven ear/ejb的pom.xml属性,jar文件是maven依赖项的一部分,spring,maven,maven-plugin,Spring,Maven,Maven Plugin,我有一个maven jar文件,它作为依赖项包含在maven ejb中。以下说明所有项目结构: 1) 父级的pom.xml(报告服务): com.xxx.pdf.reports 报告家长 2.0.0-SNAPSHOT 聚甲醛 报告-家长 报告应用程序 报告服务 2) ear的pom.xml(报告应用程序): com.xxx.pdf.reports 报告家长 2.0.0-SNAPSHOT 报告应用程序 耳朵 com.xxx.pdf.reports 报告服务 ${project.version} e

我有一个maven jar文件,它作为依赖项包含在maven ejb中。以下说明所有项目结构:

1) 父级的pom.xml(报告服务):

com.xxx.pdf.reports
报告家长
2.0.0-SNAPSHOT
聚甲醛
报告-家长
报告应用程序
报告服务
2) ear的pom.xml(报告应用程序):
com.xxx.pdf.reports
报告家长
2.0.0-SNAPSHOT
报告应用程序
耳朵
com.xxx.pdf.reports
报告服务
${project.version}
ejb
3) ejb的pom.xml(报告服务):
com.xxx.pdf.reports
报告家长
2.0.0-SNAPSHOT
报告服务
ejb
com.xxx.common.serviceframework
服务框架
1.1.0-快照
……其他依赖项。。。。。。。。。。
................
4) jar(ServiceFramework)的pom.xml:
com.xxx.common.serviceframework
服务框架
1.0.0-SNAPSHOT
如上所述,报表服务是构建报表应用程序和报表服务的父pom。这两个都是它的模块

报表应用程序只是一个包含报表服务(ejb)的ear

报表服务包含ServiceFramework(jar)作为其依赖项。此ServiceFramework包含连接到数据库以保存信息的代码。现在这个ServiceFramework可以被任何ebj(在我的项目中有很多这样的)包含在报告服务中,以保存信息

现在,我想从ServiceFramework中的java代码中获取reports服务的版本(以及其他一些pom.xml信息,如groupId&&artifactId)。我尝试使用maven资源插件

<resources>
    <resource>
        <directory>src/main/resources</directory>
        <filtering>true</filtering>
    </resource>
</resources>

src/main/resources
真的
但它给了我ServiceFramework的版本,因为选择版本的java代码在ServiceFramework jar中。我想要使用ServiceFramework jar的应用程序的版本。我尝试了所有方法,但所有方法都提供了ServiceFramework的版本


该需求是这样的,ServiceFramework应该能够获取ejb的pom信息,该ejb将pom信息作为其依赖项包含在内。那么,如何从ServiceFramework获取/读取reports服务的pom信息呢

我认为你已经接近解决方案了。您试图使用
过滤
ServiceFramework
中“捕获”groupId&artifactId&version(又名GAV)。相反,在
报告服务中使用
过滤
,捕获GAV并写入某些资源文件,比如
x.properties

位于ServiceFramework中的java代码应该从类路径加载resource x.properties并读取所有需要的内容

<resources>
    <resource>
        <directory>src/main/resources</directory>
        <filtering>true</filtering>
    </resource>
</resources>