开发中会遇到的Maven问题解惑
多模块系统版本控制问题 在开发想保持项目下的所有子模块版本一致,可以使用${rversion}变量 配置父pom <groupId>cn.imcompany</groupId> <artifactId>big-parent</artifactId> <version>${revision}</version> <packaging>pom</packaging> <modules> <module>big-web</module> </modules> <properties> <revision>1.0.0</revision> </properties> 子模块配置 <parent> <groupId>cn.imcompany</groupId> <artifactId>big-parent</artifactId> <version>${revision}</version> </parent> <artifactId>big-web</artifactId> 修改版本方式 直接修改revision变量的值 使用 mvn clean package -Drevision=1.1.0 进行配置 使用revision后Deploy操作不显示正确版本问题 需要配合 Flatten Maven Plugin 即可解决,父pom中需要增加以下配置: <build> <plugins> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>flatten-maven-plugin</artifactId> <version>1.2.2</version> <configuration> <updatePomFile>true</updatePomFile> </configuration> <executions> <execution> <id>flatten</id> <phase>process-resources</phase> <goals> <goal>flatten</goal> </goals> </execution> <execution> <id>flatten.clean</id> <phase>clean</phase> <goals> <goal>clean</goal> </goals> </execution> </executions> </plugin> </plugins> </build> 配置指定项目不发布到远程仓库 在新版本的deploy插件已经支持配置,配置skip变量即可 <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-deploy-plugin</artifactId> <version>3.0.0-M2</version> <configuration> <skip>true</skip> </configuration> </plugin> Reference Maven: POM files without a version in it? - SoftwareEntwicklung Beratung Schulung