本地的jar包添加到maven库中 jdbc举例

1.配置(检查)Java环境变量

2.配置(检查)maven环境变量

3.找到maven文件的根目录下的config目录,修改setting.xml文件

配置maven本地仓库

  1. <!-- localRepository  
  2.  | The path to the local repository maven will use to store artifacts.  
  3.  |  
  4.  | Default: ${user.home}/.m2/repository  
  5. <localRepository>/path/to/local/repo</localRepository>  
  6. -->  
  7.   
  8. <!--配置maven本地仓库-->  
  9. <localRepository>D:/java/to/local/repo</localRepository>     

4.使用阿里中央仓库

  1. <mirrors>  
  2.   <!-- mirror  
  3.    | Specifies a repository mirror site to use instead of a given repository. The repository that  
  4.    | this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used  
  5.    | for inheritance and direct lookup purposes, and must be unique across the set of mirrors.  
  6.    |  
  7.   <mirror>  
  8.     <id>mirrorId</id>  
  9.     <mirrorOf>repositoryId</mirrorOf>  
  10.     <name>Human Readable Name for this Mirror.</name>  
  11.     <url>http://my.repository.com/repo/path</url>  
  12.   </mirror>  
  13.    -->  
  14.   
  15. <!--使用阿里云-->  
  16.  <mirror>  
  17.       <id>nexus-aliyun</id>  
  18.       <mirrorOf>*</mirrorOf>  
  19.       <name>Nexus aliyun</name>  
  20.       <url>http://maven.aliyun.com/nexus/content/groups/public</url>  
  21.   </mirror>   
  22.     
  23.   
  24. </mirrors>  

5. 打开DOS窗口,执行:

mvn install:install-file -Dfile=C:/ojdbc5.jar -DgroupId=com.oracle -DartifactId=ojdbc5 -Dversion=5.0 -Dpackaging=jar -generatePom=true (如果报错就把-generatePom=true去掉)

-Dfile=c:/ojdbc5.jar  是指你ojdbc5.jar的文件位置

-DgroupId=com.oracle  

-DartifactId=ojdbc5

-Dversion=5.0

指明了ojdbc5.jar的maven仓库位置。

6.在pom.xml文件中配置

  1. <dependency>  
  2.     <groupId>com.oracle</groupId>  
  3.     <artifactId>ojdbc5</artifactId>  
  4.     <version>5.0</version>  
  5. </dependency>

7.右键点击项目-->Maven-->Update Project    此时就可以看到Maven Dependencies 有自己想要的jar包

在cmd中 mvn命令不能使用时 http://blog.csdn.net/u010782846/article/details/52775774

原链接 http://blog.csdn.net/maofachang/article/details/61932547

原文地址:https://www.cnblogs.com/ITxiaojiayu/p/7477346.html