gpt4 book ai didi

spring - 带有Gradle的Eclipselink/Spring引导。获取QueryDslPredicateExecutor的ClassNotFoundException

转载 作者:行者123 更新时间:2023-12-03 03:59:00 26 4
gpt4 key购买 nike

使用以下gradle脚本生成的一个简单的可执行jar就是ClassNotFoundException

group 'com.acme'
version '1.0-SNAPSHOT'

buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:2.0.1.RELEASE")
}


}

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'

bootJar {
baseName = 'acme-project1'
version = '0.1.0'
}

jar {
manifest {
attributes 'Main-Class': 'com.acme.ApplicationLoader'
attributes 'Spring-Boot-Classes': 'BOOT-INF/classes/'
attributes 'Spring-Boot-Lib': 'BOOT-INF/lib/'
}
}


repositories {
mavenCentral()
mavenLocal()
}

sourceCompatibility = 1.8
targetCompatibility = 1.8

ext {
queryDslVersion = '4.1.4'

}

dependencies {
compile("org.springframework.boot:spring-boot-starter-web")
compile("org.springframework.boot:spring-boot-starter-data-jpa"){
exclude group: "org.hibernate", module: "hibernate-entitymanager"
}
compile("org.springframework.boot:spring-boot-starter-data-rest")

compile "com.querydsl:querydsl-root:$queryDslVersion"
compile "com.querydsl:querydsl-jpa:$queryDslVersion"
compile "com.querydsl:querydsl-apt:$queryDslVersion:jpa"

compile("com.a:acme-persistence:1.0-SNAPSHOT")

testCompile("junit:junit")

}

注意:所有 DAO层代码都打包在一个单独的jar acme-persistence中,并作为 compile()依赖项添加

注2 :我还有另一个项目,该项目也依赖于 acme-persistence,它是使用maven构建的并且运行良好。解压缩并比较软件包后,除了 META-INF/MANIFEST.MF文件之外,其他所有内容都相似。在工作 jar 中有以下几行:
Spring-Boot-Classes: BOOT-INF/classes/
Spring-Boot-Lib: BOOT-INF/lib/

gradle内置的jar中缺少的东西。因此,我将它们添加到了gradle项目中,并在解压缩后验证了这些行是否存在。但是,仍然出现相同的错误!

错误:
java.lang.NoClassDefFoundError: org/springframework/data/querydsl/QueryDslPredicateExecutor
at java.lang.ClassLoader.defineClass1(Native Method) ~[na:1.8.0_25]
at java.lang.ClassLoader.defineClass(ClassLoader.java:760) ~[na:1.8.0_25]
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) ~[na:1.8.0_25]
at java.net.URLClassLoader.defineClass(URLClassLoader.java:455) ~[na:1.8.0_25]
at java.net.URLClassLoader.access$100(URLClassLoader.java:73) ~[na:1.8.0_25]
at java.net.URLClassLoader$1.run(URLClassLoader.java:367) ~[na:1.8.0_25]
at java.net.URLClassLoader$1.run(URLClassLoader.java:361) ~[na:1.8.0_25]
at java.security.AccessController.doPrivileged(Native Method) ~[na:1.8.0_25]
at java.net.URLClassLoader.findClass(URLClassLoader.java:360) ~[na:1.8.0_25]
at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_25]
at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:93) ~[acme-project1-0.1.0.jar:na]
at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_25]
at java.lang.ClassLoader.defineClass1(Native Method) ~[na:1.8.0_25]
at java.lang.ClassLoader.defineClass(ClassLoader.java:760) ~[na:1.8.0_25]
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) ~[na:1.8.0_25]
at java.net.URLClassLoader.defineClass(URLClassLoader.java:455) ~[na:1.8.0_25]
at java.net.URLClassLoader.access$100(URLClassLoader.java:73) ~[na:1.8.0_25]
at java.net.URLClassLoader$1.run(URLClassLoader.java:367) ~[na:1.8.0_25]
at java.net.URLClassLoader$1.run(URLClassLoader.java:361) ~[na:1.8.0_25]
at java.security.AccessController.doPrivileged(Native Method) ~[na:1.8.0_25]
at java.net.URLClassLoader.findClass(URLClassLoader.java:360) ~[na:1.8.0_25]
at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_25]
at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:93) ~[acme-project1-0.1.0.jar:na]
at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_25]
at org.springframework.util.ClassUtils.forName(ClassUtils.java:274) ~[spring-core-5.0.5.RELEASE.jar!/:5.0.5.RELEASE]
at org.springframework.data.repository.config.RepositoryBeanNameGenerator.getRepositoryInterfaceFrom(RepositoryBeanNameGenerator.java:90) ~[spring-data-commons-2.0.6.RELEASE.jar!/:2.0.6.RELEASE]
at org.springframework.data.repository.config.RepositoryBeanNameGenerator.generateBeanName(RepositoryBeanNameGenerator.java:54) ~[spring-data-commons-2.0.6.RELEASE.jar!/:2.0.6.RELEASE]
at org.springframework.data.repository.config.RepositoryConfigurationSourceSupport.generateBeanName(RepositoryConfigurationSourceSupport.java:98) ~[spring-data-commons-2.0.6.RELEASE.jar!/:2.0.6.RELEASE]
at org.springframework.data.repository.config.RepositoryConfigurationDelegate.registerRepositoriesIn(RepositoryConfigurationDelegate.java:134) ~[spring-data-commons-2.0.6.RELEASE.jar!/:2.0.6.RELEASE]
at org.springframework.boot.autoconfigure.data.AbstractRepositoryConfigurationSourceSupport.registerBeanDefinitions(AbstractRepositoryConfigurationSourceSupport.java:60) ~[spring-boot-autoconfigure-2.0.1.RELEASE.jar!/:2.0.1.RELEASE]

最佳答案

问题是spring-data-jpa-1.12.2的类为QueryDslPredicateExecutor,而在QuerydslPredicateExecutor中将其重命名为spring-data-jpa-2.6.0

注意小s与大写S!

关于spring - 带有Gradle的Eclipselink/Spring引导。获取QueryDslPredicateExecutor的ClassNotFoundException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50078359/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com