简体   繁体   English

Spring Boot 1.5.13-QueryDSL查询ClassNotFoundException吗?

[英]Spring Boot 1.5.13 - QueryDSL Query ClassNotFoundException?

I am using Spring Boot 1.5.13 with QueryDSL and whenever I issue a call to a controller I get the following ClassNotFoundException 我将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

However when I check the generated package the class QAddress is there. 但是,当我检查生成的包时,类QAddress就在那里。 How do I fix this problem? 我该如何解决这个问题?

Below are my pom.xml for QueryDSL : 以下是我的QueryDSL pom.xml

        <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>

When you are building or deploying your application, just verify whether there is any warning like invalid loc header (bad signature) for any specific jar (in your case that might be jar related to QAddress class). 在构建或部署应用程序时,只需验证是否有任何警告,例如针对任何特定jar(在您的情况下可能与QAddress类相关的jar )无效的loc标头(错误的签名 )。

If it is showing this error for any jar, then remove that folder from .m2 repository and rebuild it, then it will download that jar again and try restarting your application. 如果任何jar都显示此错误,请从.m2存储库中删除该文件夹并重建它,然后它将再次下载该jar并尝试重新启动应用程序。

For anyone having the same trouble, this issue was related to NetBeans. 对于同样遇到麻烦的人,此问题与NetBeans有关。 When I started using Intellij IDEA the issue was resolved. 当我开始使用Intellij IDEA时,问题已解决。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM