作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我是 Gradle 项目的新手,我有一个问题。我在互联网上搜索过,但找不到我需要的东西,或者也许我不知道如何搜索。首先我要告诉你我的案例。我有一个 Gradle 项目,我想执行几个自动化测试,将来使用 jenkins,但现在我想在 Eclipse 上尝试。我在/lib 目录中有 oracle jdbc 驱动程序,这是我的 build.gradle
apply plugin: 'java'
// In this section you declare where to find the dependencies of your project
repositories {
jcenter()
//mavenCentral()
}
// In this section you declare the dependencies for your production and test code
dependencies {
compile 'org.slf4j:slf4j-api:1.7.21'
compile 'org.seleniumhq.selenium:selenium-java:2.+'
compile 'org.testng:testng:6.+'
//compile 'com.oracle:ojdbc14:10.2.0.4.0'
//testCompile 'net.sourceforge.jexcelapi:jxl:2.6.12'
testCompile 'info.cukes:cucumber-core:1.+'
testCompile 'info.cukes:cucumber-java:1.+'
testCompile 'info.cukes:cucumber-junit:1.+'
testCompile 'junit:junit:4.12'
}
repositories {
flatDir(dir: 'libs')//, name: 'Local libs'
}
dependencies {
compile name: 'ojdbc7'
}
我想在一个类中使用这个 jdbc 驱动程序,但我不知道如何使用它。当我尝试使用 Maven 时,我使用了这种方式“import oracle.jdbc.driver.OracleDriver;”但我想这对于 Gradle 项目无效。你能帮我吗?提前致谢
最佳答案
您可以尝试为 Gradle 重用本地 Maven 存储库:
ojdbc7.jar
将 jar 安装到本地 Maven 存储库中:
mvn install:install-file -Dfile=ojdbc7.jar -DgroupId=com.oracle -DartifactId=ojdbc7 -Dversion=12.1.0.1 -Dpackaging=jar
检查您是否已将 jar 安装到 ~/.m2/
本地 Maven 存储库
在 build.gradle
文件中启用本地 Maven 存储库:
repositories {
mavenCentral()
mavenLocal()
}
dependencies {
compile ("com.oracle:ojdbc7:12.1.0.1")
}
现在您应该在项目中启用该 jar 进行编译
关于jdbc - 如何在Gradle项目中使用Oracle JDBC驱动程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37458661/
我是一名优秀的程序员,十分优秀!