一、在maven安装目录 /conf/setting.xml 中的servers下添加账户信息:
<servers> <server> <id>exm-admin</id> <username>admin</username> <password>admin</password> </server> <server> <id>exm-releases</id> <username>admin</username> <password>admin</password> </server> </servers>
二、配置pom
<!-- 发布maven私服 --> <distributionManagement> <repository> <id>exm-snapshots</id> <name>tuohang-framework-SNAPSHOTS</name> <url>http://47.100.xxx.xxx:30010/repository/3rd-part/</url> </repository> <snapshotRepository> <id>exm-repository</id> <name>tuohang-framework-REPOSITORY</name> <url>http://47.100.xxx.xxx:30010/repository/3rd-part/</url> </snapshotRepository> </distributionManagement>
使用deploy命令上传,在项目路径下使用命令:
mvn deploy -Dmaven.test.skip=true 或者:mvn deploy:deploy-file -Dmaven.test.skip=true -Dfile=D:\workspace\com.xxx.test-1.0.0.jar -DgroupId=com.xxx -DartifactId=test -Dversion=1.0.0-SNAPSHOT -Dpackaging=jar -DrepositoryId=exm-repository -Durl=http://192.168.xxx.xxx:9090/repository/3rd-part/
使用的时候
<!-- 远程exm仓库 --> <repositories> <repository> <id>exm-snapshots</id> <url>http://47.100.xxx.xxx:30010/repository/3rd-part/</url> </repository> <repository> <id>exm-repository</id> <url>http://47.100.xxx.xxx:30010/repository/3rd-part/</url> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>exm-snapshots</id> <url>http://47.100.xxx.xxx:30010/repository/3rd-part/</url> </pluginRepository> <pluginRepository> <id>exm-repository</id> <url>http://47.100.xxx.xxx:30010/repository/3rd-part/</url> </pluginRepository> </pluginRepositories>
但是我使用mvn命令显示不是内部命令,所以我使用了eclipse的run:
右击项目,依次执行:
Run As -->
Run Configurations --->
Maven Build --->
New _Configuration(双击Maven Build可生成) -->
Browse Workspace 选中项目,
Goals输入 :
deploy -e
点击 Run
idea的话,配置好后直接双击 maven下的 deploy命令即可。