我的演示有一个Maven-Dependencies,它包含一个ojdbc6.jar。
我想用Gradle构建一个可运行的jar。 当我运行:gradle build in命令行。它工作正常,并创建一个Test.jar
在build / libs文件夹中。当我运行:java -jar Test.jar。它显示:无法加载类:找不到oracle.jdbc.OracleDriverclass。 任何人都可以帮助我吗?非常感谢!
引起:java.lang.ClassNotFoundException:无法从ClassLoader加载类:oracle.jdbc.OracleDriver:org.springframework.boot.loader.LaunchedURLClass ssLoader:org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl$TcclSafeAggregatedClassLoader@60cbbfcd at org.apache.tomcat.jdbc.pool.ClassLoaderUtil.loadClass(ClassLoaderUtil.java:56) 在org.apache.tomcat.jdbc.pool.PooledConnection.connectUsingDriver(PooledConnection.java:268) ...省略了46个常见帧 引起:java.lang.ClassNotFoundException:无法加载请求的类:oracle.jdbc.OracleDriver at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl $ AggregatedClassLoader.findClass(ClassLoaderServiceImpl.java:230) at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl $ TcclSafeAggregatedClassLoader.findClass(ClassLoaderServiceImpl.java:456) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Unknown Source) 在org.apache.tomcat.jdbc.pool.ClassLoaderUtil.loadClass(ClassLoaderUtil.java:38)
答案 0 :(得分:2)
我已经解决了!
请访问oracle.com下载!
mvn install:install-file -Dfile = f:\ ojdbc7.jar -DgroupId = com.oracle.weblogic -DartifactId = ojdbc7 - Dversion = 12.1.0.2.0 -Dpackaging = jar
C:\用户\ Administrator.m2 \库\ COM \ ORACLE \的WebLogic \ ojdbc7 \ 12.1.0.2.0
这是我的build.gradle:
buildscript {
repositories {
mavenCentral()
maven { url "http://repo.spring.io/libs-release" }
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-
plugin:1.2.4.RELEASE")
}
}
apply plugin: "java"
apply plugin: "eclipse"
apply plugin: "idea"
apply plugin: "spring-boot"
jar {
baseName = "Test"
version = "0.1.0"
}
repositories {
mavenCentral()
mavenLocal();
maven { url "http://repo.spring.io/libs-release" }
}
dependencies {
compile("org.springframework.boot:spring-boot-starter-web")
compile("org.springframework.boot:spring-boot-starter-thymeleaf")
compile("org.springframework.boot:spring-boot-starter-data-jpa")
compile("org.springframework.flex:spring-flex-core:1.6.0.RC1")
compile("com.oracle.weblogic:ojdbc7:12.1.0.2.0")
testCompile("org.springframework.boot:spring-boot-starter-test")
}
task wrapper(type: Wrapper) {
gradleVersion = "2.4"
}
tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
}