当前位置: 首页 > 知识库问答 >
问题:

eclipse中的querydsl不在maven项目中生成查询类型类

单于善
2023-03-14

我无法在eclipse中生成querydsl Q类。如果有人能提供帮助,我们将不胜感激。下面是我尝试过的方法和pom中的代码片段。xml文件

我复制了建议的插件设置位于这里:

https://github.com/querydsl/apt-maven-plugin/wiki/m2e-usage

M2E,并将maven生成的源文件夹作为eclipse源文件夹

我已经确保安装了Maven并更改了我的eclipse。要运行JDK的ini文件,如下所述:

在Querydsl中生成Qclass时,您需要使用JDK运行构建,或者tools.jarMaven构建和JDK的类路径Eclipse问题

我已经转到项目文件夹,运行了mvn generate sources,并将该文件夹添加到类路径中。尽管如此,项目仍然找不到任何生成的Q类,我在目标文件夹中也没有看到任何生成的Q类。如果有人有任何见解,我将不胜感激。谢谢

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
    <classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
    <classpathentry exported="true" 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 exported="true" 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="src" output="target/classes" path="src/main/java">
        <attributes>
            <attribute name="optional" value="true"/>
            <attribute name="maven.pomderived" value="true"/>
        </attributes>
    </classpathentry>
    <classpathentry kind="src" path="target/generated-sources"/>
    <classpathentry kind="src" path="src/main/webapp/WEB-INF/tld"/>
    <classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
        <attributes>
            <attribute name="maven.pomderived" value="true"/>
        </attributes>
    </classpathentry>
    <classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
        <attributes>
            <attribute name="maven.pomderived" value="true"/>
        </attributes>
    </classpathentry>
    <classpathentry kind="output" path="target/classes"/>
</classpath>



<properties>
 <java-version>1.8</java-version>
 <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
 <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
 <querydsl.version>3.7.4</querydsl.version>

 </properties>

 <dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-framework-bom</artifactId>
            <version>4.2.5.RELEASE</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
 </dependencyManagement>


 <dependencies>
 <!--  <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
    </dependency>-->

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-web</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-orm</artifactId>
    </dependency>

 <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-tx</artifactId>
    </dependency>


 <!-- web services -->
 <dependency>
        <groupId>org.springframework.ws</groupId>
        <artifactId>spring-ws-core</artifactId>
        <version>2.2.4.RELEASE</version>
    </dependency>

    <!-- security -->
    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-web</artifactId>
        <version>4.0.4.RELEASE</version>
    </dependency>

    <dependency>
 <groupId>org.springframework.security</groupId>
 <artifactId>spring-security-taglibs</artifactId>
 <version>4.0.4.RELEASE</version>
 </dependency>

 <dependency>
 <groupId>org.springframework.security</groupId>
 <artifactId>spring-security-config</artifactId>
 <version>4.0.4.RELEASE</version>
 </dependency>

  <!-- HDIV SECURITY 
  <dependency>
      <groupId>org.hdiv</groupId>
      <artifactId>hdiv-core</artifactId>
      <version>2.1.3</version>
  </dependency>

  <dependency>
      <groupId>org.hdiv</groupId>
      <artifactId>hdiv-config</artifactId>
      <version>2.1.3</version>
  </dependency>

  <dependency>
      <groupId>org.hdiv</groupId>
      <artifactId>hdiv-spring-mvc</artifactId>
      <version>2.1.3</version>
  </dependency>

  <dependency>
      <groupId>org.hdiv</groupId>
      <artifactId>hdiv-jstl-taglibs-1.2</artifactId>
      <version>2.1.3</version>
  </dependency>-->

 <dependency>
   <groupId>org.hibernate</groupId>
   <artifactId>hibernate-core</artifactId>
   <version>5.1.0.Final</version>
 </dependency>

 <dependency>
 <groupId>org.hibernate</groupId>
 <artifactId>hibernate-validator</artifactId>
 <version>5.2.4.Final</version>
 </dependency>


 <dependency>
 <groupId>mysql</groupId>
 <artifactId>mysql-connector-java</artifactId>
 <version>5.1.38</version>
 </dependency>


 <!-- https://mvnrepository.com/artifact/org.springframework.data/spring-data-commons-core 
 <dependency>
    <groupId>org.springframework.data</groupId>
    <artifactId>spring-data-commons-core</artifactId>
    <version>1.4.1.RELEASE</version>
 </dependency>-->

    <!--  <dependency>
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-releasetrain</artifactId>
            <version>Gosling-SR4</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>-->

    <dependency>
 <groupId>javax.mail</groupId>
 <artifactId>javax.mail-api</artifactId>
 <version>1.5.5</version>
 </dependency>

 <dependency>
 <groupId>org.json</groupId>
 <artifactId>json</artifactId>
 <version>20160212</version>
 </dependency>

 <dependency>
 <groupId>io.jsonwebtoken</groupId>
 <artifactId>jjwt</artifactId>
 <version>0.6.0</version>
 </dependency>

   <dependency>
 <groupId>log4j</groupId>
 <artifactId>log4j</artifactId>
 <version>1.2.17</version>
 </dependency>




 <dependency>
 <groupId>commons-io</groupId>
 <artifactId>commons-io</artifactId>
 <version>2.4</version>
 </dependency>

 <dependency>
 <groupId>org.apache.commons</groupId>
 <artifactId>commons-lang3</artifactId>
 <version>3.4</version>
 </dependency>

 <dependency>
 <groupId>org.apache.commons</groupId>
 <artifactId>commons-email</artifactId>
 <version>1.4</version>
 </dependency>

      <!-- JSON -->
 <dependency>
 <groupId>com.fasterxml.jackson.core</groupId>
 <artifactId>jackson-core</artifactId>
 <version>2.7.4</version>
 </dependency>


    <dependency>
 <groupId>com.fasterxml.jackson.core</groupId>
 <artifactId>jackson-databind</artifactId>
 <version>2.7.4</version>
 </dependency>


 <dependency>
 <groupId>com.fasterxml.jackson.core</groupId>
 <artifactId>jackson-annotations</artifactId>
 <version>2.7.4</version>
 </dependency>


   <dependency>
 <groupId>com.fasterxml.jackson.datatype</groupId>
 <artifactId>jackson-datatype-hibernate5</artifactId>
 <version>2.7.4</version>
 </dependency>


 <dependency>
 <groupId>com.fasterxml.jackson.datatype</groupId>
 <artifactId>jackson-datatype-jdk8</artifactId>
 <version>2.7.4</version>
 </dependency>

 <dependency>
 <groupId>org.modelmapper</groupId>
 <artifactId>modelmapper</artifactId>
 <version>0.7.5</version>
 </dependency>



<!--  
 <dependency>
 <groupId>com.fasterxml.jackson</groupId>
 <artifactId>jackson-datatype-json-org</artifactId>
 <version>1.8.0</version>
 </dependency>

 <dependency>
 <groupId>org.codehaus.jackson</groupId>
 <artifactId>jackson-mapper-asl</artifactId>
 <version>1.9.13</version>
 </dependency>-->

    <!-- SMS and voice calls 
    <dependency>
    <groupId>com.twilio.sdk</groupId>
    <artifactId>twilio-java-sdk</artifactId>
    <version>3.4.5</version>
 </dependency>-->

    <dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>jstl</artifactId>
    <version>1.2</version>
 </dependency>

  <!-- https://mvnrepository.com/artifact/joda-time/joda-time -->
 <dependency>
    <groupId>joda-time</groupId>
    <artifactId>joda-time</artifactId>
    <version>2.9.4</version>
 </dependency>

   <!-- aws IoT -->
  <dependency>
    <groupId>com.amazonaws</groupId>
    <artifactId>aws-iot-device-sdk-java</artifactId>
    <version>1.0.1</version>
  </dependency>

  <dependency>
    <groupId>com.amazonaws</groupId>
    <artifactId>aws-iot-device-sdk-java-samples</artifactId>
    <version>1.0.1</version>
  </dependency>


 <!-- https://mvnrepository.com/artifact/com.amazonaws/aws-java-sdk-dynamodb -->
 <dependency>
    <groupId>com.amazonaws</groupId>
    <artifactId>aws-java-sdk-dynamodb</artifactId>
    <version>1.11.33</version>
 </dependency>

 <dependency>
  <groupId>com.github.derjust</groupId>
  <artifactId>spring-data-dynamodb</artifactId>
  <version>4.3.1</version>
 </dependency>


  <!-- https://mvnrepository.com/artifact/org.springframework/spring-context-support -->
 <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-context-support</artifactId>
 </dependency>

  <!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient -->
 <dependency>
    <groupId>org.apache.httpcomponents</groupId>
    <artifactId>httpclient</artifactId>
    <version>4.5.2</version>
 </dependency>

 <dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>javax.servlet-api</artifactId>
    <version>3.1.0</version>
 </dependency>


  <!-- Querydsl -->


      <dependency>
          <groupId>com.mysema.querydsl</groupId>
          <artifactId>querydsl-apt</artifactId>
          <version>${querydsl.version}</version>

      </dependency>
      <dependency>
          <groupId>com.mysema.querydsl</groupId>

          <artifactId>querydsl-jpa</artifactId>
          <version>${querydsl.version}</version>
      </dependency>

  <!-- persistence -->

      <dependency>
          <groupId>org.springframework.data</groupId>
          <artifactId>spring-data-jpa</artifactId>
          <version>1.9.0.RELEASE</version>
      </dependency>

      <dependency>
          <groupId>org.hibernate</groupId>
          <artifactId>hibernate-entitymanager</artifactId>
          <version>5.1.0.Final</version>
      </dependency>
 <!-- 
 <dependency>
    <groupId>io.springfox</groupId>
    <artifactId>springfox-swagger2</artifactId>
    <version>2.3.1</version>
 </dependency>

  <dependency>
        <groupId>org.webjars</groupId>
        <artifactId>bootstrap</artifactId>
        <version>3.3.5</version>
    </dependency>
       <dependency>
        <groupId>io.springfox</groupId>
        <artifactId>springfox-swagger-ui</artifactId>
        <version>2.2.2</version>
    </dependency>
 -->
           <!-- -AWS 
 <dependency>
 <groupId>com.amazonaws</groupId>
 <artifactId>aws-java-sdk-iot</artifactId>
 <version>1.10.62</version>
 </dependency>

 <dependency>
 <groupId>com.amazonaws</groupId>
 <artifactId>aws-java-sdk-core</artifactId>
 <version>1.10.64</version>
 </dependency>


 <dependency>
 <groupId>com.amazonaws</groupId>
 <artifactId>aws-java-sdk-machinelearning</artifactId>
 <version>1.10.64</version>
 </dependency>-->

 <!-- reporting 
 <dependency>
  <groupId>ar.com.fdvs</groupId>
  <artifactId>DynamicJasper</artifactId>
  <version>5.0.7</version>
 </dependency>-->
    </dependencies>

更多......

<plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-war-plugin</artifactId>
                    <version>2.4</version>
                    <configuration>
                        <warSourceDirectory>src/main/webapp</warSourceDirectory>
                        <warName>webmanager</warName>
                        <failOnMissingWebXml>false</failOnMissingWebXml>
                    </configuration>
                </plugin>
               <plugin>
 <groupId>org.apache.maven.plugins</groupId>
 <artifactId>maven-compiler-plugin</artifactId>
 <configuration>
 <source>1.8</source>
 <target>1.8</target>
 </configuration>
 </plugin>

 <plugin>
  <groupId>com.mysema.maven</groupId>
  <artifactId>apt-maven-plugin</artifactId>

  <version>1.0.5</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.mysema.querydsl</groupId>
      <artifactId>querydsl-apt</artifactId>

      <version>${querydsl.version}</version>

    </dependency>
    <dependency>
      <groupId>com.mysema.querydsl</groupId>

      <artifactId>querydsl-jpa</artifactId>
      <classifier>apt</classifier>
      <version>${querydsl.version}</version>
    </dependency>
  </dependencies>
 </plugin>
 <plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>build-helper-maven-plugin</artifactId>
  <executions>
    <execution>
      <id>add-source</id>
      <phase>generate-sources</phase>
      <goals>
        <goal>add-source</goal>
      </goals>
      <configuration>
        <sources>
          <source>${project.build.directory}/generated-sources/java/</source>
        </sources>
      </configuration>
    </execution>
  </executions>
 </plugin>
    </plugins>

共有2个答案

叶煌
2023-03-14

尝试将此设置为您的eclipse.ini文件并重新启动eclipse,以确保它也使用您的JDK:

-vm
C:\jdk1.7\bin\javaw.exe

注意:这必须在-vmargs的正上方。您的虚拟机的完整路径可能与上面的路径不同

进入运行配置并设置VM参数

-vm {path to jdk javaw.exe}
扶隐水
2023-03-14

QueryDsl正在生成到文件夹中的目标/生成-源/java,但是您添加了目标/生成-源作为源文件夹。

<outputDirectory>target/generated-sources/java</outputDirectory>

vs

<classpathentry kind="src" path="target/generated-sources"/>
 类似资料:
  • 请帮助我的Q型不生成 我遵循《贝尔东指南》: https://www.baeldung.com/rest-api-search-language-spring-data-querydsl 此行有多个标记 com类型。querydsl。果心类型。无法解析谓词。它间接引用自required。类文件 无法解析插件。确保插件的groupId、artifactId和version存在。其他信息:插件com。

  • 在我的pom里。xml,我添加了这个依赖项: 当我通过在终端执行“mvn clean install”编译并安装项目时,模型类在以下目录中生成: 然后,如果我从Eclipse导入这个Maven项目,它可以很好地工作,而不会抱怨自动生成的模型类。 但是,如果我不在终端执行“mvn清洁安装”来生成模型类并直接导入清洁项目,Eclipse就不会生成模型类,因此会生成编译错误。 在导入和编译干净的mave

  • 例如,JPA标准API可以在没有生成元模型的情况下使用。失去了类型安全性,但我可以在运行时仅使用反射来创建查询,而无需事先了解数据模型。我想以同样的方式使用Querydsl。我不关心类型安全问题,因为我不知道数据模型。 在我最近的项目中,我想使用Querydsl,主要是因为它构成了持久性之上的另一层。所以我希望可以在JPA、JDO、JDBC、Lucene、Hibernate Search、Mong

  • 问题内容: 当我尝试使用生成Eclipse项目文件时,出现以下错误: 插件管理器中执行目标’org.apache.maven.plugins:maven-eclipse- plugin:2.9-SNAPSHOT:eclipse’的内部错误:无法加载mojo’org.apache.maven.plugins:maven- eclipse-plugin:插件``org .apache.maven.pl

  • 我有一个Maven(eclipse)项目,我想将其转换为Maven工件,以便其他人可以从中生成新项目。 要创建工件,我做了: cd到我的proj dir,pom。xml存在 在此之后,我可以看到 。m2\存储库已添加我的项目<但是 现在,我不确定该在标记中给出什么,因为这是一个本地存储库。 但是,我无法使用生成新项目: 它要求我选择原型,但之后我得到错误: [错误]无法执行目标组织。阿帕奇。专家插