Mavendeploy怎么配置
Maven deploy 怎么配置
在本地的pom⽂件配置好之后,执⾏deploy命令,可以将maven所打的jar包上传到远程的repository,便于其他开发者和⼯程共享。l配置
⾸选,在pom⽂件中project标签下添加如下代码:
<distributionManagement>
<repository>
<id>releases</id>
<name>Internal Releases</name>
</repository>
<snapshotRepository>
<id>releases</id>
<name>Internal Releases</name>
</snapshotRepository>
</distributionManagement>
此时,执⾏deploy命令,会返回401错误,则需要⽤户验证或验证的信息有误。
在setting配置⽂件的servers标签下添加如下代码:
<server>
<id>releases</id>
<username>admin</username>
<password>admin</password>
</server>
PS:其中此处的id,必须为pom⽂件中配置的repository的id。
注意事项
⼀般继承 parent 的version会按照如下格式写:
<parent>
<groupId>module.some</groupId>
<artifactId>module_parent</artifactId>
<version>${parent.version}</version>
</parent>
这样写⽅便统⼀管理版本信息,但发布到maven私服之后,maven 会试图下载 module_parent 的 ${parent.version} 的 jar。显然,这个jar 是不存在的。那么为什么已经指定了 parent.version 的值了却没有解析呢?这是因为deploy 的过程中,parent 标签⾥的变量是不会解析的,必须是⼀个常量。
结果
执⾏maven deploy命令成功之后,登录私服进⾏查询,即可看到对应的jar包。
maven deploy命令打包到私服
<project xmlns="/POM/4.0.0" xmlns:xsi="/2001/XMLSchema-instance"
<modelVersion>4.0.0</modelVersion>
<groupId&lan.app</groupId>
<artifactId>seller-auth</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<!-- 项⽬编码 -->
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<lombok.version>1.16.10</lombok.version>
<mybatis.paginator.version>1.2.17.2</mybatis.paginator.version>
<hibernate.validator.version>5.1.2.Final</hibernate.validator.version>
<validation.api.version>1.1.0.Final</validation.api.version>
</properties>
<!-- 远程仓库地址 -->
<pluginRepositories>
<pluginRepository>
<id>nexus</id>
<name>Team Nexus Repository</name>
</pluginRepository>
</pluginRepositories>
<!-- 配置远程发布到私服,mvn deploy -->
<distributionManagement>
<!-- 定义releases库的坐标 -->
<repository>
<id>releases</id>
<name>Nexus Release Repository</name>
</repository>
<!-- 定义snapshots库 -->
<snapshotRepository>
<id>snapshots</id>
<name>Nexus Snapshot Repository</name>
</snapshotRepository>
</distributionManagement>
<!-- 项⽬有依赖的所有jar坐标配置 -->
<dependencies>
<!-- lombok jar -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</dependency>
<!-- mybatis分页插件jar -->
<dependency>
<groupId>com.github.miemiedev</groupId>
<artifactId>mybatis-paginator</artifactId>
<version>${mybatis.paginator.version}</version> </dependency>
<!-- hibernate validator验证jar -->
maven打包本地jar包<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>${hibernate.validator.version}</version> </dependency>
<!-- hibernate validtor需要的依赖 jar -->
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>${validation.api.version}</version>
</dependency>
</dependencies>
<build>
<finalName>seller-auth</finalName>
<!-- 插件库声明 -->
<plugins>
<!-- 配置运⾏环境JDK版本 -->
<plugin>
<artifactId>maven-compiler-plugin</artifactId> <extensions>true</extensions>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<!-- 将源码打包插件 -->
<plugin>
<artifactId>maven-source-plugin</artifactId>
<version>2.1</version>
<configuration>
<attach>true</attach>
</configuration>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- deploy时只上传jar包到远程仓库的配置 -->
<plugin>
<artifactId>maven-deploy-plugin</artifactId> <version>2.7</version>
<executions>
<execution>
<id>default-deploy</id>
<phase>deploy</phase>
<goals>
<goal>deploy</goal>
</goals>
<!-- skip默认deploy插件的执⾏ -->
<configuration>
<skip>true</skip>
</configuration>
</execution>
<execution>
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论