title: Query DSL & Maven: Classes not generated, but only on command line (in eclipse it is working fine)
body: <p>We are using a setup with Spring Boot, Hibernate, Query DSL and Maven with Java 1.8</p>
  
  <p>Recently, I've added Query DSL to the project with the configuration listed below. To make it work, I had to configure the Java Compiler in the eclipse project settings to allow Annotation Processing and also add the Query DSL <code>.jar</code> file to the eclipse Annotation Factory Path.</p>
  
  <p>This setup worked as expected. It generated the custom <code>Q</code> classes and I could use them in my code. When now running the <code>mvn clean install</code> on the command line, every class in my code throws the error <code>cannot find symbol</code>, because the class is missing. Is there anything else I need to configure - similar to the <code>.jar</code> file in the eclipse settings - to make the build process work?</p>
  
  <p><strong>EDIT:</strong> This question is not a duplicate of <a href="https://stackoverflow.com/questions/25706216/what-does-a-cannot-find-symbol-compilation-error-mean">this question</a> because I did not ask why this error (cannot find a symbol) occurs but rather how to configure QueryDSL to also work on the command line.</p>
  
  <p><strong>EDIT2:</strong> I have now tried to integrate the <code>build-helper-maven-plugin</code> to use multiple source paths as an input. This did not help either. I also tried to generate the files into a <code>src</code> folder. It did not help either.</p>
  
  <p>When I first compile the library in eclipse, the <code>mvn compile</code> goes through on the command line, but <code>mvn clean compile</code> still fails, because it just uses the compiled files of eclipse again. The apt-maven-plugin is executed, which can be seen just before the build process fails:</p>
  
  <pre><code>[INFO] --- apt-maven-plugin:1.1.3:process (default) @ project1 ---
  [INFO]
  [INFO] --- build-helper-maven-plugin:1.9.1:add-source (add-source) @ project1 ---
  [INFO] Source directory: C:\Users\user1\git\project1\src\main\generated added.
  [INFO]
  [INFO] --- maven-processor-plugin:2.2.4:process (process) @ project1 ---
  [ERROR] diagnostic: [...]
  </code></pre>
  
  <p><strong>EDIT3:</strong> When I remove every import statement which is referring to the <code>Q</code> classes, the build process goes through (obviously). It is, however, remarkable, that the <code>Q</code> classes get compiled correctly in that case. They appear in the <code>target</code> folder as <code>.class</code> files as they should. Could it be, that the <code>Q</code> classes are compiled too late?</p>
  
  <hr>
  
  <p><strong>Here is an excerpt of the <code>pom.xml</code></strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  
      [...]
      &lt;prerequisites&gt;
          &lt;maven&gt;3.0.0&lt;/maven&gt;
      &lt;/prerequisites&gt;
  
      &lt;dependencies&gt;
          [...]
          &lt;dependency&gt;
              &lt;groupId&gt;com.querydsl&lt;/groupId&gt;
              &lt;artifactId&gt;querydsl-apt&lt;/artifactId&gt;
              &lt;version&gt;4.1.3&lt;/version&gt;
              &lt;scope&gt;provided&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.querydsl&lt;/groupId&gt;
              &lt;artifactId&gt;querydsl-jpa&lt;/artifactId&gt;
              &lt;version&gt;4.1.3&lt;/version&gt;
          &lt;/dependency&gt;
      &lt;/dependencies&gt;
  
      &lt;build&gt;
          &lt;defaultGoal&gt;spring-boot:run&lt;/defaultGoal&gt;
          &lt;plugins&gt;
              [...]
              &lt;plugin&gt;
                  &lt;groupId&gt;com.mysema.maven&lt;/groupId&gt;
                  &lt;artifactId&gt;apt-maven-plugin&lt;/artifactId&gt;
                  &lt;version&gt;1.1.3&lt;/version&gt;
                  &lt;executions&gt;
                      &lt;execution&gt;
                          &lt;goals&gt;
                              &lt;goal&gt;process&lt;/goal&gt;
                          &lt;/goals&gt;
                          &lt;configuration&gt;
                              &lt;outputDirectory&gt;target/generated-sources/java&lt;/outputDirectory&gt;
                              &lt;processor&gt;com.querydsl.apt.jpa.JPAAnnotationProcessor&lt;/processor&gt;
                          &lt;/configuration&gt;
                      &lt;/execution&gt;
                  &lt;/executions&gt;
              &lt;/plugin&gt;
          &lt;/plugins&gt;
          [...]
      &lt;/build&gt;
  &lt;/project&gt;
  </code></pre>
  
  <p><strong>This is the configuration of the eclipse project settings:</strong></p>
  
  <p><a href="https://i.stack.imgur.com/dmEE6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dmEE6.png" alt="enter image description here"></a></p>
  
  <p><strong>This is the error message which is displayed in the console:</strong></p>
  
  <pre><code>[INFO] --- maven-processor-plugin:2.2.4:process (process) @ project1 ---
  [ERROR] diagnostic: C:\Users\user1\git\project1\src\main\java\com\project1\repository\UserRepositoryImpl.java:3: error: cannot find symbol
  import static com.project1.domain.QUser.user;
                                       ^
    symbol:   class QUser
    location: package com.project1.domain
  
  [ERROR] diagnostic: C:\Users\user1\git\project1\src\main\java\com\project1\repository\UserRepositoryImpl.java:3: error: static import only from classes and interfaces
  import static com.project.domain.QUser.user;
  ^
  </code></pre>