releases: online version (used in production environment)
snapshots: snapshot version (used during development)
When maven packages code to a private server, it can be distinguished whether it is packaging the online version or the snapshot version according to whether there is "-SNAPSHOTS" behind the version. If "-SNAPSHOTS" is included, the snapshot version is packaged, otherwise it is the online version.
- Define version using placeholders
- Set the default version in properties
- Set different versionpom configurations according to different profiles in profiles
- mvn deploy uses the default version for packaging; mvn deploy -p Prod packages and sets the version
-
<?xml version="1.0" encoding="UTF-8"?> <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.boloni</groupId> <artifactId>appollo-gfs-parent</artifactId> <version>${project.release.version}</version> <packaging>pom</packaging> <name>appollo-gfs-parent</name> <url>http://www.xxxxx.com</url> <description>[email protected]</description> <properties> <project.release.version>0.1-SNAPSHOT</project.release.version> </properties> <profiles> <profile> <id>prod</id> <properties> <project.release.version>0.1</project.release.version> </properties> </profile> </profiles> <distributionManagement> <repository> <id>releases</id> <url>http://xxxxxx:8070/nexus/content/repositories/releases</url> </repository> <snapshotRepository> <id>snapshots</id> <url>http://xxxxx:8070/nexus/content/repositories/snapshots</url> </snapshotRepository> </distributionManagement> </project>