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

时间:2023-03-08 20:37:28

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. <!--配置maven本地仓库-->
  8. <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. <mirror>
  16. <id>nexus-aliyun</id>
  17. <mirrorOf>*</mirrorOf>
  18. <name>Nexus aliyun</name>
  19. <url>http://maven.aliyun.com/nexus/content/groups/public</url>
  20. </mirror>
  21. </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.****.net/u010782846/article/details/52775774

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