问题描述
我似乎无法让 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:
将jar文件下载到我的机器上
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.)
cd 进入我保存 ojdb6.jar 的目录并从那里运行命令第一次工作.
cd-ing into the directory where I keep ojdb6.jar and running the command from there worked the first time.
如果拉古拉姆想回答这个问题,我会接受他的回答.谢谢大家!
If Raghuram would like to answer this question, I'll accept his answer instead. Thanks everyone!
这篇关于Oracle JDBC ojdbc6 Jar 作为 Maven 依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!