当我在pom.xml
中添加以下代码以支持 Querydsl 时
<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>
</plugin>
使用Eclipse进行构建时出现此错误。我认为它与classpath和JDK jars有关系
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 :
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jst.server.core.container/org.eclipse.jst.server.tomcat.runtimeTarget/Apache Tomcat v8.0">
<attributes>
<attribute name="owner.project.facets" value="jst.web"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
额外信息:
我的Maven安装
JAVA_HOME:C:\ Program Files \ Java \ jdk1.7.0_45
PATH:%JAVA_HOME%\ bin;
最佳答案
解决方案1
跟随此link
因此,我使用控制台mvn generate-sources
在我的项目选单中执行了命令行cmd
,并生成了我的Qclasses。
解决方案2来自@ informatik01的注释
我们可以像这样在eclipse.ini
中明确显示specified JVM:
-vm
C:\Program Files\Java\jdk1.7.0_45\bin\javaw.exe
-vmargs
...
-vm
选项必须出现在-vmargs
选项之前,有关更多信息,请阅读下面的@ informatik01注释。