Maven-Maven中添加Oracle驱动包到本地仓库
生活随笔
收集整理的這篇文章主要介紹了
Maven-Maven中添加Oracle驱动包到本地仓库
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
- 問題
- 解決辦法
- 1 確認本機安裝了Maven
- 2下載對應版本的數據庫驅動
- 官方下載jar
- 通過本地安裝目錄查找
- oracle的驅動包說明
- 3安裝驅動到本地倉庫
- pomxml 中使用Oracle驅動包
問題
因Oracle授權問題,Maven3不提供Oracle JDBC 對應的驅動jar包。 因此 ,如果在在Maven項目中使用Oracle JDBC driver,必須手動添加到本地倉庫。
解決辦法
1、 確認本機安裝了Maven
在命令窗口通過mvn -v查看版本
E:\libs\oracle>mvn -v Apache Maven 3.5.0 (ff8f5e7444045639af65f6095c62210b5713f426; 2017-04-03T15:39:06-04:00) Maven home: E:\libs\apache-maven-3.5.0-bin\apache-maven-3.5.0\bin\.. Java version: 1.7.0_51, vendor: Oracle Corporation Java home: E:\Program Files\Java\jdk1.7.0_51\jre Default locale: zh_CN, platform encoding: GBK OS name: "windows 8", version: "6.2", arch: "amd64", family: "windows"2、下載對應版本的數據庫驅動
官方下載jar:
http://www.oracle.com/technetwork/database/features/jdbc/index-091264.html
查看自己的數據庫版本,下載對應版本的jar包
Oracle Database 11g Release 2 (11.2.0.4), (11.2.0.3), (11.2.0.2.0), (11.2.0.1.0) drivers 對應的 jar包為 ojdbc6.jar
通過本地安裝目錄查找
如果你在本機裝了oracle,在 {ORACLE_HOME}\jdbc\lib下查找
oracle的驅動包說明
classes12.jar - for Java 1.2 and 1.3ojdbc14.jar - for Java 1.4 and 1.5ojdbc5.jar - for Java 1.5ojdbc6.jar - for Java 1.6因此最高的版本 目前是 ojdbc6 .
3、安裝驅動到本地倉庫
進入到對應的目錄,執行 mvn install 命令
Microsoft Windows [版本 10.0.14393] (c) 2016 Microsoft Corporation。保留所有權利。C:\Users\Mr.Yang>E:E:\>cd libsE:\libs>cd oracleE:\libs\oracle>mvn install:install-file -DgroupId=com.oracle -DartifactId=ojdbc6 -Dversion=11.2.0.4.0 -Dpackaging=jar -Dfile=ojdbc6.jar [INFO] Scanning for projects... Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-clean-plugin/2.5/maven-clean-plugin-2.5.pom Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-clean-plugin/2.5/maven-clean-plugin-2.5.pom (3.9 kB at 3.3 kB/s) Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-install-plugin/2.4/maven-install-plugin-2.4.pom Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-install-plugin/2.4/maven-install-plugin-2.4.pom (6.4 kB at 24 kB/s) [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building Maven Stub Project (No POM) 1 [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- maven-install-plugin:2.4:install-file (default-cli) @ standalone-pom --- Downloading: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-utils/3.0.5/plexus-utils-3.0.5.pom Downloaded: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-utils/3.0.5/plexus-utils-3.0.5.pom (2.5 kB at 11 kB/s) Downloading: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-digest/1.0/plexus-digest-1.0.pom Downloaded: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-digest/1.0/plexus-digest-1.0.pom (1.1 kB at 4.3 kB/s) Downloading: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-components/1.1.7/plexus-components-1.1.7.pom Downloaded: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-components/1.1.7/plexus-components-1.1.7.pom (5.0 kB at 14 kB/s) Downloading: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus/1.0.8/plexus-1.0.8.pom Downloaded: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus/1.0.8/plexus-1.0.8.pom (7.2 kB at 17 kB/s) Downloading: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-container-default/1.0-alpha-8/plexus-container-default-1.0-alpha-8.pom Downloaded: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-container-default/1.0-alpha-8/plexus-container-default-1.0-alpha-8.pom (7.3 kB at 24 kB/s) Downloading: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-utils/3.0.5/plexus-utils-3.0.5.jar Downloading: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-digest/1.0/plexus-digest-1.0.jar Downloaded: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-digest/1.0/plexus-digest-1.0.jar (12 kB at 7.9 kB/s) Downloaded: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-utils/3.0.5/plexus-utils-3.0.5.jar (230 kB at 64 kB/s) [INFO] Installing E:\libs\oracle\ojdbc6.jar to C:\Users\Mr.Yang\.m2\repository\com\oracle\ojdbc6\11.2.0.4.0\ojdbc6-11.2.0.4.0.jar [INFO] Installing C:\Users\MR15A7~1.YAN\AppData\Local\Temp\mvninstall6899666971437725340.pom to C:\Users\Mr.Yang\.m2\repository\com\oracle\ojdbc6\11.2.0.4.0\ojdbc6-11.2.0.4.0.pom [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 7.956 s [INFO] Finished at: 2017-06-24T17:35:46-04:00 [INFO] Final Memory: 13M/192M [INFO] ------------------------------------------------------------------------E:\libs\oracle>[INFO] BUILD SUCCESS 即 OK
pom.xml 中使用Oracle驅動包
<!-- 添加oracle jdbc driver --> <dependency> <groupId>com.oracle</groupId> <artifactId>ojdbc6</artifactId> <version>${oracle.version}</version></dependency>接下來,就可以在應用中正常使用Oracle的驅動包了。
總結
以上是生活随笔為你收集整理的Maven-Maven中添加Oracle驱动包到本地仓库的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Spring-Spring 开发环境搭建
- 下一篇: Maven-Could not reso