springdata-mongo querydsl报错: java.lang.ClassNotFoundException

10-13 17:42:37   来源:shikezhi   评论: 点击:

Caused by: java.lang.IllegalArgumentException: Did not find a query class com.test.mongo.model.QBgmMessages for domain class com.test.mongo.model.BgmMessages! at org.springframework.data.querydsl.SimpleEntityPathResolver.createPath
Caused by: java.lang.IllegalArgumentException: Did not find a query class com.test.mongo.model.QBgmMessages for domain class com.test.mongo.model.BgmMessages!
at org.springframework.data.querydsl.SimpleEntityPathResolver.createPath(SimpleEntityPathResolver.java:63)
at org.springframework.data.mongodb.repository.support.QueryDslMongoRepository.<init>(QueryDslMongoRepository.java:82)
at org.springframework.data.mongodb.repository.support.QueryDslMongoRepository.<init>(QueryDslMongoRepository.java:65)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:142)
... 65 more
Caused by: java.lang.ClassNotFoundException: com.test.mongo.model.QBgmMessages
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at org.springframework.util.ClassUtils.forName(ClassUtils.java:250)
at org.springframework.data.querydsl.SimpleEntityPathResolver.createPath(SimpleEntityPathResolver.java:53)
... 72 more
 
 
 
解决办法:
pom.xml中加入apt-maven-plugin插件
<plugin>
<groupId>com.mysema.maven</groupId>
<artifactId>apt-maven-plugin</artifactId>
<version>1.1.3</version>
<executions>
<execution>
<goals>
<goal>process</goal>
</goals>
<configuration>
<outputDirectory>target/generated-sources/java</outputDirectory>
<processor>org.springframework.data.mongodb.repository.support.MongoAnnotationProcessor</processor>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>com.querydsl</groupId>
<artifactId>querydsl-apt</artifactId>
<version>4.1.0</version>
</dependency>
</dependencies>
</plugin>
 

相关热词搜索:springdata mongo querydsl报错

上一篇:springdata mongo分页查询数据时报错:maximum 33554432 bytes of RAM 下一篇:最后一页
分享到: 收藏