通过Maven添加Oracle驱动依赖的步骤及问题

一、在maven3的pom.xml中添加依赖

        <!-- Spring Boot JDBC -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jdbc</artifactId>
        </dependency>
        
        <!-- 本地oracle -->
        <dependency>
            <groupId>ojdbc</groupId>
            <artifactId>ojdbc6</artifactId>
            <version>11.2.0.4</version>
        </dependency>

二、下载Oracle驱动包

  • 官网下载

       https://www.oracle.com/technetwork/database/application-development/jdbc/downloads/index.html

  • Maven中央仓库

       http://mvnrepository.com/

  • 本地Oracle数据库安装目录中获取

       D:\Program Files\PLSQL Developer\instantclient_11_2\ojdbc6.jar(我的路径)

       注意:不知道本地Oracle的版本,可以通过 SELECT * FROM V$VERSION; 查询

       

三、将Oracle驱动包加载到Maven的本地仓库

  • mvn -version检查Maven环境变量配置
  • cmd 切换到驱动包路径下
  • mvn -X install:install-file -DgroupId=ojdbc -DartifactId=ojdbc6 -Dversion=11.2.0.4 -Dpackaging=jar -Dfile=ojdbc6.jar

       执行成功的效果:

       

四、相关问题

  • 解决办法:使用CMD命令行,不能用powershell!
[ERROR] The goal you specified requires a project to execute but there is no POM in this directory (D:\Program Files\PLSQL Developer\instantclient_11_2). Please verify you invoked Maven from the correct directory. -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MissingProjectException
  • 解决办法:通过debug模式查看报错原因,可能是settings.xml文件未配置代理导致。
[ERROR] No plugin found for prefix 'install' in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local (D:\.m2\repository), central (https://repo.maven.apache.org/maven2)] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/NoPluginFoundForPrefixException

扩展:通过Eclipse加载Oracle驱动包

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值