【问题标题】:Maven pom systemProperty path to file syntaxMaven pom systemProperty 文件语法路径
【发布时间】:2024-04-19 11:05:02
【问题描述】:

有来自pom.xml的follwong块:

<systemProperty>
    <name>axis2.config</name>
    <value>file:${project.build.directory}/../../axis2.properties</value>
</systemProperty>

value 标签的语法是什么意思?

/../ - 是 id cd .. 并转发到父目录?

【问题讨论】:

    标签: file syntax path maven properties


    【解决方案1】:

    short: ../ 表示父目录

    长版:

    • file: 指定,以下 内容应该被解释为 文件路径。
    • ${project.build.directory} 是一个 将被替换的变量 实际项目的运行时 构建目录
    • / 是文件夹分隔符
    • .. 表示父文件夹
    • axis2.properties 是名称 属性文件

    如果您想显示用于调试目的的路径,您可能想看看这个:

    http://www.avajava.com/tutorials/lessons/how-do-i-display-the-value-of-a-pom-xml-element.html

    maven ant echoproperties task

    【讨论】:

      【解决方案2】:

      是的,它是项目构建目录的相对路径,并且向上(在父级中)两次。

      换句话说:它是包含您的项目构建目录的目录的父目录;)

      来源: Maven Properties Guide

      【讨论】:

      • 哦,谢谢你,Alois。是否可以看到整个路径的样子?我的意思是显示这个变量值,也许在 out.println 的某个地方?
      • 我不这么认为,但是如果你的项目构建目录在我们说:/home/sergio/projects/myproject/target --> /home/sergio/projects/axis2.properties
      • 您可以在这里找到更多信息:docs.codehaus.org/display/MAVENUSER/MavenPropertiesGuide希望对您有所帮助!