我将Spring Boot 1.5.13与QueryDSL一起使用,每当我向控制器发出调用时,我都会得到以下ClassNotFoundException
Caused by: java.lang.ClassNotFoundException: api.model.QAddress
at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[na:1.8.0_121]
at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_121]
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) ~[na:1.8.0_121]
at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_121]
at org.springframework.boot.devtools.restart.classloader.RestartClassLoader.loadClass(RestartClassLoader.java:161) ~[spring-boot-devtools-1.5.13.RELEASE.jar:1.5.13.RELEASE]
at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_121]
... 211 common frames omitted
<dependency>
<groupId>com.querydsl</groupId>
<artifactId>querydsl-apt</artifactId>
</dependency>
<dependency>
<groupId>com.querydsl</groupId>
<artifactId>querydsl-jpa</artifactId>
</dependency>
<plugin>
<groupId>com.mysema.maven</groupId>
<artifactId>maven-apt-plugin</artifactId>
<version>1.0</version>
<executions>
<execution>
<goals>
<goal>process</goal>
</goals>
<configuration>
<outputDirectory>target/generated-sources</outputDirectory>
<processor>com.querydsl.apt.jpa.JPAAnnotationProcessor</processor>
</configuration>
</execution>
</executions>
</plugin>
在构建或部署应用程序时,只需验证任何特定jar(在您的例子中,可能是与QAddress类相关的jar)是否存在任何警告,如无效的loc头(错误的签名)。
如果它对任何jar都显示此错误,那么从。m2存储库中删除该文件夹并重新构建它,然后它将再次下载该jar并尝试重新启动应用程序。