如何从外部属性文件中获取POM.xml的依赖项部分中的groupId,artifactId,versionId

问题描述

我想从pom.xml中的属性文件替换groupId,artifactId,versionIdb。我已经经历了所有的堆栈溢出解决方案。但是没有什么帮助我。我的dev.properties具有以下属性。

log4j.groupId=log4j
log4j.artifactId=log4j
log4j.version=1.2.11
log4j.jar=log4j-1.2.11.jar

下面是我的pom.xml内容

<project>
<build>
        <plugins>

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>properties-maven-plugin</artifactId>
                <version>1.0.0</version>
                <executions>
                    <execution>
                        <phase>initialize</phase>
                        <goals>
                            <goal>read-project-properties</goal>
                        </goals>
                        <configuration>
                            <files>
                                <file>src/main/resources/etc/dev.properties</file>
                            </files>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
</build>
    
    <dependencies>
        <dependency>
            <groupId>${log4j.groupId}</groupId>
            <artifactId>${log4j.artifactId}</artifactId>
            <version>${log4j.version}</version>
            <scope>system</scope>
            <systemPath>${project.basedir}/${thirdparty.apache.dir}/${log4j.jar}</systemPath>
        </dependency>
    </dependencies>

</project>

但是在依赖项部分下log4j.groupId,log4j.artifactId和log4j.version不可用,并引发错误。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...