发布java库到Maven

原文   http://www.cnblogs.com/iamsach/p/9199602.html

1新建一个java库项目并且实现XXX功能(如果你的项目是maven项目可以跳过这一步)

  1. 1打开project struture

 

  1. 2新建一个resources文件夹

  1. 3然后将此目录标记为resources目录

  1. 4打开添加第三方库的菜单

  1. 5添加maven库到项目

2.此时你的项目已经是一个maven项目了,如果你的库的代码已经写好那么可以进入下面操作

  1. 1在jetbrain idea开发工具的配置文件中添加你的maven管理员账号和密码

  <servers>
    <server>
    <id>nexus</id>
    <username>admin</username>
    <password>admin123</password>
    </server>
  </servers>
  1. 2在pol.xml添加几行代码

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.wjs</groupId>
    <artifactId>Queue</artifactId>
    <version>1.0-SNAPSHOT</version>

    <distributionManagement>
        <snapshotRepository>
            <id>nexus</id>
            <name>Nexus Snapshot</name>
            <url>http://192.168.1.9/nexus-2.14.10-01/content/repositories/snapshots/</url>
        </snapshotRepository>
        <repository>
            <id>nexus</id>
            <name>Nexus Release</name>
            <url>http://192.168.1.9/nexus-2.14.10-01/content/repositories/releases/</url>
        </repository>
    </distributionManagement>

    <build>
        <plugins>
            <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>
        </plugins>
    </build>
</project>
  1. 3发布maven项目

 

然后在其他项目中引入

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>groupId</groupId>
    <artifactId>untitled1</artifactId>
    <version>1.0-SNAPSHOT</version>
    <dependencies>
        <dependency>
            <groupId>com.wjs</groupId>
            <artifactId>Queue</artifactId>
            <version>1.0-SNAPSHOT</version>
        </dependency>
    </dependencies>
    <repositories>
        <repository>
            <id>nexus</id>
            <name>Nexus Release</name>
            <url>http://192.168.1.9/nexus-2.14.10-01/content/repositories/snapshots/</url>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
            <releases>
                <enabled>true</enabled>
            </releases>
        </repository>
    </repositories>
</project>

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值