最佳答案
我似乎无法让 Maven 将 ojdbc6.jar 文件捆绑到我的项目的 war 文件中。当直接为 Hibernate 工具指定依赖项时,我让它在 POM 文件中工作。但是它不会与项目的 war 文件捆绑在一起,因此我的项目不会在 Tomcat 上运行。
我已经尝试了所有我能在网上找到的解决方案,包括这里为这个问题指定的解决方案:
在 Maven 存储库中查找 Oracle JDBC 驱动程序
最近,我做了以下事情:
把 jar 文件下载到我的机器上
运行以下命令将 jar 安装到本地存储库中:
mvn install:install-file -DgroupId=com.oracle -DartifactId=ojdbc6 -Dversion=11.2.0.3 -Dpackaging=jar -Dfile=ojdbc6.jar -DgeneratePom=true
(我也尝试了该命令的各种变体。)
最后,我将这个依赖项放到我的 pom 文件中:
<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?)
Is it because I'm on a Mac, perhaps?