title: Querydsl maven compilation error: QClass.class does not exist
body: <p>I am new to Querydsl and trying to use it in a simple test project. 
  I followed the official tutorial to configure my pom.xml, then mvn clean install was able to generated the Q Classes under target/generated-sources/java.
  But I got the error below:</p>
  
  <pre><code>[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project spring-jqgrid-tutorial: Compilation failure
  
  [ERROR] /D:/Project/spring-jqgrid-tutorial/src/main/java/org/krams/controller/UserController.java:[92,62] package QUser.user does not exist
  </code></pre>
  
  <p>I think the root cause is the generated Q class source files were not compiled automatically into binary class files. I did verify there are no QUser.class under my project directory.
  I also tried to use build-helper-maven-plugin to add target/generated-sources/java as a source folder and specify target/generated-sources/java as an additional source root in apt-maven-plugin configuration. But I got no luck.</p>
  
  <p>Here is my pom.xml</p>
  
  <pre><code>&lt;properties&gt;
      &lt;querydsl.version&gt;3.3.2&lt;/querydsl.version&gt;
      &lt;maven.compiler.plugin.version&gt;3.1&lt;/maven.compiler.plugin.version&gt;
      &lt;maven.apt.plugin.version&gt;1.1.1&lt;/maven.apt.plugin.version
      &lt;maven.build.helper.plugin.version&gt;1.8&lt;/maven.build.helper.plugin.version&gt;
  &lt;properties&gt;
  
  &lt;dependencies&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;com.mysema.querydsl&lt;/groupId&gt;
          &lt;artifactId&gt;querydsl-jpa&lt;/artifactId&gt;
          &lt;version&gt;${querydsl.version}&lt;/version&gt;
          &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;com.mysema.querydsl&lt;/groupId&gt;
          &lt;artifactId&gt;querydsl-apt&lt;/artifactId&gt;
          &lt;version&gt;${querydsl.version}&lt;/version&gt;
          &lt;scope&gt;provided&lt;/scope&gt;
      &lt;/dependency&gt;
   &lt;dependencies&gt;
  
  &lt;plugins&gt;
          &lt;plugin&gt;
              &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
              &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
              &lt;version&gt;${maven.compiler.plugin.version}&lt;/version&gt;
              &lt;configuration&gt;
                  &lt;source&gt;1.7&lt;/source&gt;
                  &lt;target&gt;1.7&lt;/target&gt;
              &lt;/configuration&gt;
          &lt;/plugin&gt;
  
          &lt;plugin&gt;
              &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;
              &lt;artifactId&gt;build-helper-maven-plugin&lt;/artifactId&gt;
                  &lt;version&gt;${maven.build.helper.plugin.version}&lt;/version&gt;
              &lt;executions&gt;
                  &lt;execution&gt;
                      &lt;id&gt;add-source&lt;/id&gt;
                      &lt;phase&gt;process-classes&lt;/phase&gt;
                      &lt;goals&gt;
                          &lt;goal&gt;add-source&lt;/goal&gt;
                      &lt;/goals&gt;
                      &lt;configuration&gt;
                          &lt;sources&gt;
                              &lt;source&gt;target/generated-sources/java&lt;/source&gt;
                          &lt;/sources&gt;
                      &lt;/configuration&gt;
                  &lt;/execution&gt;
              &lt;/executions&gt;
          &lt;/plugin&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;${maven.apt.plugin.version}&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.mysema.query.apt.jpa.JPAAnnotationProcessor&lt;/processor&gt;
                          &lt;additionalSourceRoots&gt;
                              &lt;additionalSourceRoot&gt;target/generated-sources/java&lt;/additionalSourceRoot&gt;
                          &lt;/additionalSourceRoots&gt;
                      &lt;/configuration&gt;
                  &lt;/execution&gt;
              &lt;/executions&gt;
          &lt;/plugin&gt;
  &lt;plugins&gt;
  </code></pre>
  
  <p>And here is the generated QUser.java</p>
  
  <pre><code>package org.krams.domain;
  
  import static com.mysema.query.types.PathMetadataFactory.*;
  
  import com.mysema.query.types.path.*;
  
  import com.mysema.query.types.PathMetadata;
  import javax.annotation.Generated;
  import com.mysema.query.types.Path;
  import com.mysema.query.types.path.PathInits;
  
  
  /**
   * QUser is a Querydsl query type for User
   */
  @Generated("com.mysema.query.codegen.EntitySerializer")
  public class QUser extends EntityPathBase&lt;User&gt; {
  
      private static final long serialVersionUID = -1712499619L;
  
      private static final PathInits INITS = PathInits.DIRECT2;
  
      public static final QUser user = new QUser("user");
  
      public final NumberPath&lt;Integer&gt; age = createNumber("age", Integer.class);
  
      public final StringPath firstName = createString("firstName");
  
      public final NumberPath&lt;Long&gt; id = createNumber("id", Long.class);
  
      public final StringPath lastName = createString("lastName");
  
      public final StringPath password = createString("password");
  
      public final QRole role;
  
      public final StringPath username = createString("username");
  
      public QUser(String variable) {
          this(User.class, forVariable(variable), INITS);
      }
  
      public QUser(Path&lt;? extends User&gt; path) {
          this(path.getType(), path.getMetadata(), path.getMetadata().isRoot() ? INITS : PathInits.DEFAULT);
      }
  
      public QUser(PathMetadata&lt;?&gt; metadata) {
          this(metadata, metadata.isRoot() ? INITS : PathInits.DEFAULT);
      }
  
      public QUser(PathMetadata&lt;?&gt; metadata, PathInits inits) {
          this(User.class, metadata, inits);
      }
  
      public QUser(Class&lt;? extends User&gt; type, PathMetadata&lt;?&gt; metadata, PathInits inits) {
          super(type, metadata, inits);
          this.role = inits.isInitialized("role") ? new QRole(forProperty("role"), inits.get("role")) : null;
      }
  
  }
  </code></pre>
  
  <p>Below is the only reference to QUser in UserController.java. repository is an instance of UserRepository repository, which extends QueryDslPredicateExecutor.</p>
  
  <pre><code>package org.krams.controller;
  
  import java.util.List;
  
  import org.krams.domain.QUser;
  import org.krams.domain.Role;
  import org.krams.domain.User;
  import org.krams.repository.UserRepository;
  import org.krams.response.JqgridResponse;
  import org.krams.response.StatusResponse;
  import org.krams.response.UserDto;
  import org.krams.service.UserService;
  import org.krams.util.JqgridFilter;
  import org.krams.util.JqgridObjectMapper;
  import org.krams.util.UserMapper;
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.data.domain.Page;
  import org.springframework.data.domain.PageRequest;
  import org.springframework.data.domain.Pageable;
  import org.springframework.stereotype.Controller;
  import org.springframework.web.bind.annotation.RequestBody;
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.bind.annotation.RequestMethod;
  import org.springframework.web.bind.annotation.RequestParam;
  import org.springframework.web.bind.annotation.ResponseBody;
  
  ...
  
  if (qUsername != null) 
              users = repository.findAll(QUser.user.username.like(qUsername), pageRequest);
  </code></pre>
  
  <p>Appreciate your help and comments. I can provide more information if required.</p>