属性maven插件:参数';文件';为了目标。。。都不见了

属性maven插件:参数';文件';为了目标。。。都不见了,maven,maven-plugin,maven-3,Maven,Maven Plugin,Maven 3,我使用的是Maven 3.0.3。我正在尝试从属性文件中读取属性(这是一项更大的工作的一部分,我想先把这部分做好)。我的pom.xml文件中有这个 <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>maven-properties-plugin</artifactId> <version>1.0</version>

我使用的是Maven 3.0.3。我正在尝试从属性文件中读取属性(这是一项更大的工作的一部分,我想先把这部分做好)。我的pom.xml文件中有这个

  <plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>maven-properties-plugin</artifactId>
    <version>1.0</version>
    <configuration>
      <files>
        <file>${basedir}/build.properties</file>
      </files>
    </configuration>
  </plugin>

我想你把插件工件设置搞错了。正确的工件标识符是

<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.0-alpha-2</version>
org.codehaus.mojo

您确定您的
build.properties
文件在
${basedir}
中吗

${basedir}
表示包含
pom.xml

你可以参考

  • 更新至当前插件版本
    1.0-alpha-2
  • 确保
    build.properties
    文件存在于
    ${basedir}
  • 要么:
    • 使用
      mvn属性调用
      mvn
      时指定目标:读取项目属性
    • 或者将目标添加到
      pom.xml
  • 示例
    pom.xml

    <build>
      <plugins>
      ...
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>properties-maven-plugin</artifactId>
        <version>1.0-alpha-2</version>
        <executions>
          <execution>
            <phase>initialize</phase>
            <goals>
              <goal>read-project-properties</goal>
            </goals>
            <configuration>
              <files>
                <file>${basedir}/build.properties</file>
              </files>
            </configuration>
          </execution>
        </executions>
      </plugin>
      ...
      </plugins>
    </build>
    
    
    ...
    org.codehaus.mojo
    属性maven插件
    1.0-α-2
    初始化
    读取项目属性
    ${basedir}/build.properties
    ...
    
    可能与Hi有关。如果您找到了问题的解决方案,请与我们分享。我也有同样的问题。
    <build>
      <plugins>
      ...
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>properties-maven-plugin</artifactId>
        <version>1.0-alpha-2</version>
        <executions>
          <execution>
            <phase>initialize</phase>
            <goals>
              <goal>read-project-properties</goal>
            </goals>
            <configuration>
              <files>
                <file>${basedir}/build.properties</file>
              </files>
            </configuration>
          </execution>
        </executions>
      </plugin>
      ...
      </plugins>
    </build>