跟Maven相关的一些笔记 参考自joenali的个人空间 修改setting.xml,在利用mvn deploy命令将jar包上传到nexus服务器
<profile>
<id>test</id>
<repositories>
<repository>
<id>nexus</id>
<name>local_repositories</name>
<url>http://localhost:8081/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</profile>
<server>
<id>releases</id> <!-- nexus仓库的ID,比如这里选的是releases仓库 -->
<username>deployment</username> <!-- 这里使用的是nexus的帐号:deployment,可以在nexus服务器管理 -->
<password>deployment123</password> <!-- deployment帐号默认密码: deployment123 -->
</server>
<distributionManagement>
<snapshotRepository>
<id>snapshots</id>
<name>Nexus Snapshot Repository</name>
<url>http://localhost:8081/nexus/content/repositories/snapshots</url>
</snapshotRepository>
<repository>
<id>releases</id>
<name>Nexus Release Repository</name>
<url>http://localhost:8081/nexus/content/repositories/releases</url>
</repository>
</distributionManagement>
mvn deploy -DskipTests -Dsnapshots.repo=http://localhost:8081/nexus/content/repositories/snapshots -Dreleases.repo=http://localhost:8081/nexus/content/repositories/releases
生成项目原型以及用原型生成新的项目
cd /f/workspace/demo #进入项目的根目录
mvn archetype:create-from-project #运行成功后生成的项目原型保存在当前目录的\target\generated-sources\archetype下
cd \target\generated-sources\archetype
mvn install #把archetype安装到本地仓库
cd /f/workspace #在workspace文件夹下根据原型生成新的项目
mvn archetype:generate -B -DarchetypeCatalog=local -DarchetypeRepository=原型的maven仓库地址(如果在本地直接写‘local’) -DarchetypeGroupId=原型的groupId -DarchetypeArtifactId=原型的artifactId -DarchetypeVersion=原型的version -DgroupId=新项目的groupId -DartifactId=新项目的artifactId -Dpackage=新项目的包名
将jar包安装到本地仓库
mvn install:install-file -Dfile=jar位置 -DgroupId=jar包的groupId -DartifactId=jar包的artifactId -Dpackaging=jar