在Querydsl中生成Qclasses时,使用Maven构建和JDK的Eclipse问题 [英] Eclipse issue with Maven build and JDK when generating Qclasses in Querydsl

查看:252
本文介绍了在Querydsl中生成Qclasses时,使用Maven构建和JDK的Eclipse问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在我的 pom.xml 中添加以下代码以支持 Querydsl



< pre class =lang-xml prettyprint-override> < plugin>
< groupId> com.mysema.maven< / groupId>
< artifactId> apt-maven-plugin< / artifactId>
< version> 1.0.6< / version>
<执行>
< execution>
< goals>
< goal>进程< / goal>
< / goals>
< configuration>
< outputDirectory> target / generated-sources / java< / outputDirectory>
< processor> com.mysema.query.apt.jpa.JPAAnnotationProcessor< / processor>
< / configuration>
< / execution>
< / executions>
< / plugin>

使用Eclipse构建时我收到此错误。我认为它与classpath和JDK jar有关系

 您需要使用JDK运行构建或在类路径上具有tools.jar。 
如果在eclipse构建期间发生这种情况,请确保在JDK下运行eclipse以及
(com.mysema.maven:apt-maven-plugin:1.0.6:process:default:generate-sources)

.classpath

 <?xml version =1.0encoding =UTF-8?> 
< classpath>
< classpathentry kind =srcoutput =target / classespath =src>
<属性>
< attribute name =optionalvalue =true/>
< attribute name =maven.pomderivedvalue =true/>
< / attributes>
< / classpathentry>
< classpathentry kind =conpath =org.eclipse.jst.server.core.container / org.eclipse.jst.server.tomcat.runtimeTarget / Apache Tomcat v8.0>
<属性>
< attribute name =owner.project.facetsvalue =jst.web/>
< / attributes>
< / classpathentry>
< classpathentry kind =conpath =org.eclipse.jdt.launching.JRE_CONTAINER / org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType / JavaSE-1.7>
<属性>
< attribute name =maven.pomderivedvalue =true/>
< / attributes>
< / classpathentry>
< classpathentry kind =conpath =org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER>
<属性>
< attribute name =maven.pomderivedvalue =true/>
< attribute name =org.eclipse.jst.component.dependencyvalue =/ WEB-INF / lib/>
< / attributes>
< / classpathentry>
< classpathentry kind =outputpath =target / classes/>
< / classpath>



额外信息:





我的maven安装





JAVA_HOME:C:\Program Files\Java\jdk1.7.0_45

路径:%JAVA_HOME %\bin;

解决方案

解决方案1 ​​



遵循这个链接


Maven APT插件有一个已知问题,可以直接从Eclipse中禁止使用
。 Eclipse用户必须通过在命令
提示符处运行命令mvn generate-sources来手动创建Querydsl查询


所以ie使用控制台 cmd 在我的项目浮标中输入命令行 mvn generate-sources ,我得到了我的Qclasses生成。 p>

解决方案2 从@ informatik01评论



我们可以明确地指定的JVM eclipse.ini 中:

  -vm 
C:\Program Files\Java\jdk1.7.0_45\bin\javaw.exe

-vmargs
...

vm 选项必须在 -vmargs 选项之前,更多信息请阅读@ informatik01评论。


When I add this code below in my pom.xml to support 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>

I got this error when building with Eclipse. I think it has relation with classpath and 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>


Extra info :

My maven Installation

JAVA_HOME : C:\Program Files\Java\jdk1.7.0_45
PATH : %JAVA_HOME%\bin;

解决方案

SOLUTION 1

Following this link

"The Maven APT plugin has a known issue that prevents its usage directly from Eclipse. Eclipse users must create the Querydsl query types manually by running the command mvn generate-sources at command prompt."

So i execute the command line mvn generate-sources in my project floder with console cmd and i got my Qclasses generated.

SOLUTION 2 from @informatik01 comment

we can explicitly specified JVM in the eclipse.ini like that :

-vm
C:\Program Files\Java\jdk1.7.0_45\bin\javaw.exe

-vmargs
...

The -vm option must occur before the -vmargs option and for more info read @informatik01 comment below.

这篇关于在Querydsl中生成Qclasses时,使用Maven构建和JDK的Eclipse问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆