在项目开发中通常会引用其他的jar,怎样把自己的项目做为一个jar包的形式发布到私服仓库中,主要有以下三个步骤
(怎样配置maven私服仓库,就不再这里说明了,可以参考以前的文章)1.在maven的setting.xml中配置用户名和密码:
<servers>
<server>
<username>admin</username>
<password>admin123</password>
<id>nexus-release</id>
</server>
<server>
<username>admin</username>
<password>admin</password>
<id>nexus-snapshots</id>
</server>
</servers>
注意:要在nexus中打开相应的snapshots和releases仓库中的允许发布的开关
2.在发布的项目中配置pom.xml
如果有parent只需在parent中的pom.xml中配置,没有则在本项目的pom.xml配置即可
<distributionManagement>
<repository>
<id>nexus-release</id>
<url>http://192.168.0.247/nexus/content/repositories/releases/</url>
</repository>
<snapshotRepository>
<id>nexus-snapshots</id>
<url>http://192.168.0.247/nexus/content/repositories/snapshots/</url>
</snapshotRepository>
</distributionManagement> <!--上传source.jar 非必须 -->
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
3.在依赖的项目添加依赖(注意版本是snapshot还是release)
snapshot版本还是release版本取决于发布项目中的配置
例如
<properties>
<!-- 依赖的版本定义 -->
<mes.version>0.0.1-RELEASE</mes.version>
</properties>
<dependencies>
<!-- 系统消息服务 -->
<dependency>
<groupId>com.longda.message</groupId>
<artifactId>mes-core</artifactId>
<version>${mes.version}</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
</dependencies>
相应的待发布项目中配置如下
<modelVersion>4.0.0</modelVersion>
<groupId>com.longda.message</groupId>
<artifactId>mes-core</artifactId>
<version>0.0.1-RELEASE</version>
<packaging>jar</packaging>
<name>mes-core</name>
<url>http://maven.apache.org</url>
<properties>
<project.release.version>0.1-RELEASE</project.release.version>
</dependencies>
注意:简而言之就是两边的版本一定要对应上,至于是发布snapshot版本还是release版本需要在第二步中指定
分享到:
相关推荐
java maven项目打包
遍历文件夹及子文件夹下得pom文件,自动清理、编译、安装。适合批量编译多个maven工程
maven打包 maven打jar包详细步骤
IDEA中使用maven打jar包,然后使用工具混淆代码,亲测有效
maven的setting配置私有仓库 包含:阿里云的配置+本地私有的配置多个仓库
maven 瘦身打包配置信息
idea新建maven web项目.zip Jetbrains IntelliJ IDEA创建基于maven打包工具的WEB网站项目 本项目使用的是SSM框架spring mvc,spring, mybatis.用maven打包成jar
python自动化打包java maven工程,并上传至服务器,简化服务器war上传步骤和节约时间
maven+bat打包,通过在maven中配置插件执行bat脚本进行目录下的打包。
springboot(web项目,非maven)
Maven打包,指定classes路径打包到WebContent/WEB-INF中
这是一个springboot+maven写的demo,主要演示springboot项目通过maven插件,将依赖与配置文件打包到jar包外部,实现灵活的项目管理.仅供参考学习
Windows Server 2016环境下使用Nexus搭建Maven私有仓库详细过程及常用配置。
IDEA中使用maven打jar包,然后使用工具混淆代码,亲测有效
不习惯于maven项目开发,想使用eclipse的普通web项目。想借鉴别人的maven项目,但是自己使用的却不熟悉maven的原理等等,但是需要懂一点maven的目录架构。
maven项目在Linux中自动git打包发布重启Tomcat。。。。
Eclipse新建和部署maven项目,每一步都有详细的截图
非常实用的工具,将maven类java工程打包为zip格式、tar.gz格式,并且实现jar包 配置文件分离,方便部署。
使用Maven构建多模块项目
jenkins实现maven项目自动部署到tomcat 实现自动部署,