您可以像这样在 pom.xml 中定义属性:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.domain.example</groupId>
<artifactId>example-artifact</artifactId>
<version>1.0.0-SNAPSHOT</version>
<name>${project.artifactId}</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.build.compiler.version>1.6</project.build.compiler.version>
<myProperty>myValue</myProperty>
</properties>
</project>
因此在 pom.xml 或过滤文件中,您可以使用 ${myProperty} 让 maven 填写“myValue”
如果您想使用插件,本指南可能会有所帮助:http ://maven.apache.org/guides/mini/guide-configuring-plugins.html - 在配置部分中,您几乎可以做任何事情。