Oracle JDBC ojdbc6 Jar作为Maven依赖项 [英] Oracle JDBC ojdbc6 Jar as a Maven Dependency

查看:148
本文介绍了Oracle JDBC ojdbc6 Jar作为Maven依赖项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我似乎无法让Maven将ojdbc6.jar文件捆绑到项目的war文件中.直接为Hibernate工具指定依赖项时,我可以在POM文件中使用它.但是它不会与项目的war文件捆绑在一起,因此我的项目无法在Tomcat上运行.

I cannot seem to get Maven to bundle the ojdbc6.jar file into my project's war file. I have it working within the POM file when specifying a dependency directly for Hibernate tools. But it won't get bundled with the project's war file, and therefore my project won't run on Tomcat.

我尝试了所有可以在网上找到的解决方案,包括为此问题在此处指定的解决方案:

I have tried every solution I can find out there on the net, including those specified for this question here:

在Maven存储库中查找Oracle JDBC驱动程序

最近,我做了以下事情:

Most recently, I did the following:

  1. 将jar文件下载到我的机器上

  1. Download the jar file to my machine

运行以下命令以将jar安装到我的本地存储库中:

Run the following command to install the jar into my local repository:

mvn install:install-file -DgroupId=com.oracle -DartifactId=ojdbc6 -Dversion=11.2.0.3 -Dpackaging=jar -Dfile=ojdbc6.jar -DgeneratePom=true

(我也尝试过该命令的各种变体.)

(I've tried all kinds of variants of that command, too.)

最后,我将依赖项放入了pom文件:

Finally, I put the dependency into my pom file:

<dependency>
    <groupId>com.oracle</groupId>
    <artifactId>ojdbc6</artifactId>
    <version>11.2.0.3</version>
</dependency>

  • 我运行了一个干净的版本,但失败了:

  • I run a clean build, but it fails:

    mvn -U clean package
    
    [INFO] Scanning for projects...
    [INFO]                                                                         
    [INFO] ------------------------------------------------------------------------
    [INFO] Building jazztwo 0.0.1
    [INFO] ------------------------------------------------------------------------
    Downloading: http://repo1.maven.org/maven2/com/oracle/ojdbc6/11.2.0.3/ojdbc6-11.2.0.3.jar
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD FAILURE
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 0.700s
    [INFO] Finished at: Tue Mar 27 15:06:14 PDT 2012
    [INFO] Final Memory: 3M/81M
    [INFO] ------------------------------------------------------------------------
    [ERROR] Failed to execute goal on project jazztwo: Could not resolve dependencies for project edu.berkeley:jazztwo:war:0.0.1: Could not find artifact com.oracle:ojdbc6:jar:11.2.0.3 in central (http://repo1.maven.org/maven2) -> [Help 1]
    

  • 为什么这行不通?我准备把昂贵的计算机零件扔到整个房间里.这浪费了很多时间. (谢谢您,甲骨文.我们又向您支付了多少?)

    Why doesn't this work? I'm ready to throw expensive computer parts across the room. This has wasted so much time. (Thank you, Oracle. How much did we pay you again?)

    是不是因为我在Mac上?

    Is it because I'm on a Mac, perhaps?

    推荐答案

    Raghuram在评论部分为我的原始问题提供了正确答案.

    The correct answer was supplied by Raghuram in the comments section to my original question.

    无论出于何种原因,将"mvn install"指向物理ojdbc6.jar文件的完整路径对我来说不起作用. (或者在运行命令时,我一再地反复混淆它,但是没有发出错误.)

    For whatever reason, pointing "mvn install" to a full path of the physical ojdbc6.jar file didn't work for me. (Or I consistently repeatedly flubbed it up when running the command, but no errors were issued.)

    第一次进入我保存ojdb6.jar的目录,并从那里运行命令.

    cd-ing into the directory where I keep ojdb6.jar and running the command from there worked the first time.

    如果Raghuram想回答这个问题,我将接受他的回答.谢谢大家!

    If Raghuram would like to answer this question, I'll accept his answer instead. Thanks everyone!

    这篇关于Oracle JDBC ojdbc6 Jar作为Maven依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆