在maven中添加新的类库到本地代码服务器中

在maven中添加新的类库到本地代码服务器中
假设要添加库文件 richfaces-ui-3.1.3.GA.jar
1、为库 richfaces-ui-3.1.3.GA.jar文件建立pom文件 richfaces-ui-3.1.3.GA.pom
<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/maven-v4_0_0.xsd">
 <modelVersion> 4.0.0</modelVersion>
 <groupId> org.richfaces</groupId>
 <artifactId> richfaces-ui</artifactId>
 <version> 3.1.3.GA</version>
 <name>RichFaces JSF components library</name>
 <packaging>jar</packaging>
</project>
2、用ant为jar和pom文件分别生成校验文件.sha1
<project default="main">
 <target name="main" description="Generate checksum file for jar and pom">  
       <checksum algorithm="SHA" fileext=".sha1">  
           <fileset dir=" F:/software/java/richfaces-ui-3.1.3.GA/lib" id="id">   
              <include name="**/*.pom" />  
              <include name="**/*.jar" />  
              <include name="**/*.xml" />  
              <exclude name="**/*.sh1" />  
           </fileset>  
       </checksum>  
 </target>
</project>
3、在.m2目录中创建该库文件的代码库目录 .m2\repository\org\richfaces\richfaces-ui\3.1.3.GA
其中, org\richfaces为包路径, richfaces-ui为包名, 3.1.3.GA为版本,这三项是与pom文件中的 groupId,artifactId,version分别对应的。
richfaces-ui-3.1.3.GA.jar,richfaces-ui-3.1.3.GA.jar.sha1,richfaces-ui-3.1.3.GA.pom,richfaces-ui-3.1.3.GA.pom.sha1拷贝到该目录下。
4、在工程的pom文件中添加依赖
<dependency>
 <groupId> org.richfaces</groupId>
 <artifactId> richfaces-ui</artifactId>
 <version> 3.1.3.GA</version>
</dependency>

--------------------

    WE准高手

你可能感兴趣的:(在maven中添加新的类库到本地代码服务器中)