原文 http://www.cnblogs.com/iamsach/p/9199602.html
1新建一个java库项目并且实现XXX功能(如果你的项目是maven项目可以跳过这一步)
- 1打开project struture
- 2新建一个resources文件夹
- 3然后将此目录标记为resources目录
- 4打开添加第三方库的菜单
- 5添加maven库到项目
2.此时你的项目已经是一个maven项目了,如果你的库的代码已经写好那么可以进入下面操作
- 1在jetbrain idea开发工具的配置文件中添加你的maven管理员账号和密码
<servers>
<server>
<id>nexus</id>
<username>admin</username>
<password>admin123</password>
</server>
</servers>
- 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>
- 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>