您的位置:首页 > 编程语言 > Java开发

Maven私服配置简介(Eclipse端)

2017-05-09 00:00 381 查看
Maven 私服配置

1、settings.xml 文件配置

需要增加如下内容,这里的重点是私有云的设置,注意不要设置反啦!

<!-- 阿里云 -->
<mirror>
<id>alimaven</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>

<!-- 私有云 -->
<mirror>
<id>neo4j</id>
<name>neo4j</name>
<url>http://xxx.xx.xx.xxx:8081/repository/neo4j/</url>
<mirrorOf>alimaven</mirrorOf> <!-- 注意这里的配置,要让私有云镜像阿里云  -->
</mirror>

<!-- 私有云用户名、密码 -->
<servers>
<server>
<id>maven-releases</id>
<username>admin</username>
<password>xxxxxxxxxx</password>
</server>
<server>
<id>maven-snapshots</id>
<username>admin</username>
<password> xxxxxxxxxx</password>
</server>
</servers>

<!-- 发布部署到私服 -->
<!-- 把这段放到settings.xml文件的<profiles></profiles>中,好处是,就不用每个工程的pom项目都加啦, 而且也安全,打包里不存在私服信息 -->
<profile>
<id>neo4j</id>
<repositories>
<repository>
<id>maven-releases</id>
<name>maven-releases</name>
<url>http://xxx.xx.xx.xxx:8081/repository/maven-releases/</url>
</repository>
<repository>
<id>maven-snapshots</id>
<name>maven-snapshots</name>
<url>http://xxx.xx.xx.xxx:8081/repository/maven-snapshots/</url>
</repository>
</repositories>
</profile>

注意:如果在settings.xml中配置了上文的<profile>就不需要如下的配置了

2、项目 pom.xml 文件增加如下配置

需要增加如下内容

<!-- 部署到私服 -->
<distributionManagement>
<repository>
<id>maven-releases</id>
<name>maven-releases</name>
<url>http://xxx.xx.xx.xxx:8081/repository/maven-releases/</url>
</repository>
<snapshotRepository>
<id>maven-snapshots</id>
<name>maven-snapshots</name>
<url>http://xxx.xx.xx.xxx :8081/repository/maven-snapshots/</url>
</snapshotRepository>
</distributionManagement>

3、项目pom.xml文件增加如下配置,通过maven生产源码包和文档包并发布到私服

添加如下内容到<build><plugins>...</plugins></build>中,具体内容如下:

<!-- 生成javadoc文档包的插件 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.4</version>
<configuration>
<aggregate>true</aggregate>
</configuration>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>

<!-- 生成sources源码包的插件 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.0.1</version>
<configuration>
<attach>true</attach>
</configuration>
<executions>
<execution>
<!-- execution下可配置phase属性, 意思是在什么阶段打包源文件。如package -->
<phase>package</phase>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>

欢迎大家关注懒也要有正确的方式公众号

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: