如何通过 Gradle 将 ojdbc7 添加到 Java Web 应用程序? [英] How to add ojdbc7 to Java web app by Gradle?
问题描述
我的背景:
- 我构建了一个基于 Spring Boot 的 Java Web 应用程序1.3.5. 发布.
- 我尝试将
ojdcb
添加到依赖项列表但没有成功. - 我知道 Oracle 在
http://maven.oracle.com
- I build a Java web application what based on Spring Boot 1.3.5.RELEASE .
- I try to add
ojdcb
to dependencies list but not success. - I know that Oracle has own Maven repository at
http://maven.oracle.com
这是我的 build.gradle
文件,让我们关注第 4、5、6、36 行:
This is my build.gradle
file, Let focus at line 4, 5, 6, 36:
buildscript {
repositories {
mavenCentral()
maven {
url ("https://maven.oracle.com")
}
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.3.5.RELEASE")
}
}
apply plugin: 'war'
apply plugin: 'idea'
apply plugin: 'spring-boot'
jar {
baseName = 'erp'
version = '1.0.0'
}
repositories {
mavenCentral()
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
dependencies {
compile("org.springframework.boot:spring-boot-starter-thymeleaf")
//compile("org.springframework.boot:spring-boot-starter-security")
providedRuntime("org.springframework.boot:spring-boot-starter-tomcat")
compile("org.springframework.boot:spring-boot-starter-data-jpa")
compile("org.hibernate:hibernate-core")
compile("com.oracle.jdbc:ojdbc7:12.1.0.2")
testCompile("junit:junit")
}
IntelliJ IDEA 2016 提示错误:
IntelliJ IDEA 2016 notice error:
警告:根项目erp":Web Facets/Artifacts 将不会正确配置 详情:org.gradle.api.artifacts.ResolveException:无法解决所有问题配置 ':runtime' 的依赖项.造成的:org.gradle.internal.resolve.ModuleVersionNotFoundException:无法找到 com.oracle.jdbc:ojdbc7:12.1.0.2.要求::erp: 未指定
Warning:root project 'erp': Web Facets/Artifacts will not be configured properly Details: org.gradle.api.artifacts.ResolveException: Could not resolve all dependencies for configuration ':runtime'. Caused by: org.gradle.internal.resolve.ModuleVersionNotFoundException: Could not find com.oracle.jdbc:ojdbc7:12.1.0.2. Required by: :erp:unspecified
(相关链接:http://docs.oracle.com/middleware/1213/core/MAVEN/config_maven_repo.htm#MAVEN9015https://blogs.oracle.com/dev2dev/entry/how_to_get_oracle_jdbchttps://blogs.oracle.com/dev2dev/entry/oracle_maven_repository_instructions_for)
帮我把ojdbc
添加到Gradle的依赖列表中,谢谢!
Help me add ojdbc
to dependencies list by Gradle, thank you!
推荐答案
For Oracle database 12c
For Oracle database 12c
(1) 在 Oracle 主页下载 ojdbc7.jar
.
(1) Download ojdbc7.jar
at Oracle homepage.
(2) 运行命令
mvn install:install-file -Dfile=ojdbc7.jar -DgroupId=com.oracle -DartifactId=ojdbc7 -Dversion=12.1.0.1 -Dpackaging=jar
(3) 添加到 build.gradle
compile('com.oracle:ojdbc7:12.1.0.1')
这篇关于如何通过 Gradle 将 ojdbc7 添加到 Java Web 应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!