当我在下面添加此代码pom.xml
以支持Querydsl时
com.mysema.maven
apt-maven-plugin
1.0.6
process
target/generated-sources/java
com.mysema.query.apt.jpa.JPAAnnotationProcessor
使用Eclipse构建时出现此错误.我认为它与classpath和JDK jar有关系
You need to run build with JDK or have tools.jar on the classpath. If this occures during eclipse build make sure you run eclipse under JDK as well (com.mysema.maven:apt-maven-plugin:1.0.6:process:default:generate-sources)
.classpath:
额外信息:
我的maven安装
JAVA_HOME:C:\ Program Files\Java\jdk1.7.0_45
路径:%JAVA_HOME%\ bin;
你可以在pom中试试这个:
<plugin> <groupId>com.mysema.maven</groupId> <artifactId>apt-maven-plugin</artifactId> <version>1.0.6</version> <executions> <execution> <goals> <goal>process</goal> </goals> <configuration> <outputDirectory>target/generated-sources/java</outputDirectory> <processor>com.mysema.query.apt.jpa.JPAAnnotationProcessor</processor> </configuration> </execution> </executions> <dependencies> <dependency> <groupId>com.sun</groupId> <artifactId>tools</artifactId> <version>1.7</version> <scope>system</scope> <systemPath>${java.home}/../lib/tools.jar</systemPath> </dependency> </dependencies> </plugin>
并看看它是否有任何改变.它应该在构建路径中强制tools.jar.
编辑.既然没有帮助,请尝试指定
-vm D:/work/Java/jdk1.6.0_13/bin/javaw.exe
在eclipse.ini中(单独的行很重要),如本主题中所述.
解决方案1
点击此链接
"行家APT插件有一个已知的问题,直接阻止其使用从Eclipse中.Eclipse用户必须通过运行在命令提示命令MVN产生来源手动创建Querydsl查询类型".
所以我mvn generate-sources
在我的项目floder中使用控制台执行命令行,cmd
然后生成了我的Qclasses.
解决方案2来自@ informatik01评论
我们可以明确地指定JVM在eclipse.ini
这样的:
-vm C:\Program Files\Java\jdk1.7.0_45\bin\javaw.exe -vmargs ...
该-vm
选项必须在-vmargs
选项之前发生,有关更多信息,请阅读下面的@ informatik01评论.