Constructor threw exception; nested exception is java.lang.IllegalArgumentException: Did not find a query...





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







2















I created a maven project in sts and I am trying to create a war file for the project. I also have querydsl configured for my classes. One class is giving me a error response when I run maven install. ERROR: Error creating bean with name 'productBrandController' defined in file [C:UsersvinceDocumentsworkspace-spring-tool-suite-4-4.0.1.RELEASEprojecttargettest-classescomprojectprojectStoreBasedProductBrandController.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'productBrandRepository': Invocation of init method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.data.mongodb.repository.support.QuerydslMongoPredicateExecutor]: Constructor threw exception; nested exception is java.lang.IllegalArgumentException: Did not find a query class project.QProductBrand for domain class project.StoreBased.ProductBrand! I need help with my pom file (Not sure if javax.xml.bind might be the culprit) and I am also not sure if my output directory is correct (I already tried java instead of annotations as output). Much thanks for the help!



This is the class



import java.util.ArrayList;
import java.util.List;

import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.index.IndexDirection;
import org.springframework.data.mongodb.core.index.Indexed;
import org.springframework.data.mongodb.core.mapping.Document;


@Document(collection = "ProductBrand")
public class ProductBrand {

@Id
private String id;
private ProductsBasic basic;
@Indexed(direction = IndexDirection.ASCENDING)
private String name;
@Indexed(direction = IndexDirection.ASCENDING)
private String units;
@Indexed(direction = IndexDirection.ASCENDING)
private double price;
@Indexed(direction = IndexDirection.ASCENDING)
private double price100g;
private String manufacturer;
private List<Manufacturer> manufacturerIndex;
private boolean organic;
private List<Organic> organicIndex;
private String category;
private List<Category> categoryIndex;
private String subCategory;
private List<SubCategory> subCategoryIndex;
private boolean seasonal;
private List<Seasonal> seasonalIndex;
private boolean frozenGoods;
private List<FrozenGoods> frozenGoodsIndex;
private boolean refrigeratedGoods;
private List<RefrigeratedGoods> refrigeratedGoodsIndex;
private boolean available;
private List<Available> availableIndex;
@Indexed(direction = IndexDirection.ASCENDING)
private String store;
private List<Store> storeIndex;

// public ProductBrand() {
// super();
// }

public ProductBrand() {
this.setAvailableIndex(new ArrayList<>());
this.setCategoryIndex(new ArrayList<>());
this.setSubCategoryIndex(new ArrayList<>());
this.setFrozenGoodsIndex(new ArrayList<>());
this.setManufacturerIndex(new ArrayList<>());
this.setOrganicIndex(new ArrayList<>());
this.setRefrigeratedGoodsIndex(new ArrayList<>());
this.setSeasonalIndex(new ArrayList<>());
this.setStoreIndex(new ArrayList<>());
}

public ProductBrand(String id, ProductsBasic basic, String name, String units, double price, double price100g,
String manufacturer, List<Manufacturer> manufacturerIndex, boolean organic, List<Organic> organicIndex,
String category, List<Category> categoryIndex, String subCategory, List<SubCategory> subCategoryIndex,
boolean seasonal, List<Seasonal> seasonalIndex, boolean frozenGoods, List<FrozenGoods> frozenGoodsIndex,
boolean refrigeratedGoods, List<RefrigeratedGoods> refrigeratedGoodsIndex, boolean available,
List<Available> availableIndex, String store, List<Store> storeIndex) {
super();
this.id = id;
this.basic = basic;
this.name = name;
this.units = units;
this.price = price;
this.price100g = price100g;
this.manufacturer = manufacturer;
this.setManufacturerIndex(manufacturerIndex);
this.organic = organic;
this.setOrganicIndex(organicIndex);
this.category = category;
this.setCategoryIndex(categoryIndex);
this.subCategory = subCategory;
this.setSubCategoryIndex(subCategoryIndex);
this.seasonal = seasonal;
this.setSeasonalIndex(seasonalIndex);
this.frozenGoods = frozenGoods;
this.setFrozenGoodsIndex(frozenGoodsIndex);
this.refrigeratedGoods = refrigeratedGoods;
this.setRefrigeratedGoodsIndex(refrigeratedGoodsIndex);
this.available = available;
this.setAvailableIndex(availableIndex);
this.store = store;
this.setStoreIndex(storeIndex);
}

public String getManufacturer() {
return manufacturer;
}

public void setManufacturer(String manufacturer) {
this.manufacturer = manufacturer;
}

public boolean isOrganic() {
return organic;
}

public void setOrganic(boolean organic) {
this.organic = organic;
}

public String getCategory() {
return category;
}

public void setCategory(String category) {
this.category = category;
}

public String getSubCategory() {
return subCategory;
}

public void setSubCategory(String subCategory) {
this.subCategory = subCategory;
}

public boolean isSeasonal() {
return seasonal;
}

public void setSeasonal(boolean seasonal) {
this.seasonal = seasonal;
}

public boolean isFrozenGoods() {
return frozenGoods;
}

public void setFrozenGoods(boolean frozenGoods) {
this.frozenGoods = frozenGoods;
}

public boolean isRefrigeratedGoods() {
return refrigeratedGoods;
}

public void setRefrigeratedGoods(boolean refrigeratedGoods) {
this.refrigeratedGoods = refrigeratedGoods;
}

public boolean isAvailable() {
return available;
}

public void setAvailable(boolean available) {
this.available = available;
}

public void addProduktBrand(ProductBrand productBrand) {
ProductBrand.add(productBrand);
}

public static void add(ProductBrand productBrand) {
}

public String getId() {
return id;
}

public void setId(String id) {
this.id = id;
}

public ProductsBasic getBasic() {
return basic;
}

public void setBasic(ProductsBasic basic) {
this.basic = basic;
}

public String getStore() {
return store;
}

public void setStore(String store) {
this.store = store;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String getUnits() {
return units;
}

public void setUnits(String units) {
this.units = units;
}

public double getPrice() {
return price;
}

public void setPrice(double price) {
this.price = price;
}

public double getPrice100g() {
return price100g;
}

public void setPrice100g(double price100g) {
this.price100g = price100g;
}

public List<Manufacturer> getManufacturerIndex() {
return manufacturerIndex;
}

public void setManufacturerIndex(List<Manufacturer> manufacturerIndex) {
this.manufacturerIndex = manufacturerIndex;
}

public List<Organic> getOrganicIndex() {
return organicIndex;
}

public void setOrganicIndex(List<Organic> organicIndex) {
this.organicIndex = organicIndex;
}

public List<Category> getCategoryIndex() {
return categoryIndex;
}

public void setCategoryIndex(List<Category> categoryIndex) {
this.categoryIndex = categoryIndex;
}

public List<SubCategory> getSubCategoryIndex() {
return subCategoryIndex;
}

public void setSubCategoryIndex(List<SubCategory> subCategoryIndex) {
this.subCategoryIndex = subCategoryIndex;
}

public List<Seasonal> getSeasonalIndex() {
return seasonalIndex;
}

public void setSeasonalIndex(List<Seasonal> seasonalIndex) {
this.seasonalIndex = seasonalIndex;
}

public List<FrozenGoods> getFrozenGoodsIndex() {
return frozenGoodsIndex;
}

public void setFrozenGoodsIndex(List<FrozenGoods> frozenGoodsIndex) {
this.frozenGoodsIndex = frozenGoodsIndex;
}

public List<RefrigeratedGoods> getRefrigeratedGoodsIndex() {
return refrigeratedGoodsIndex;
}

public void setRefrigeratedGoodsIndex(List<RefrigeratedGoods> refrigeratedGoodsIndex) {
this.refrigeratedGoodsIndex = refrigeratedGoodsIndex;
}

public List<Available> getAvailableIndex() {
return availableIndex;
}

public void setAvailableIndex(List<Available> availableIndex) {
this.availableIndex = availableIndex;
}

public List<Store> getStoreIndex() {
return storeIndex;
}

public void setStoreIndex(List<Store> storeIndex) {
this.storeIndex = storeIndex;
}

}


This is the controller of the class



import java.util.List;
import java.util.Optional;

import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import project.QProductBrand;
import com.querydsl.core.types.dsl.BooleanExpression;


@RestController
@RequestMapping("/productbrand")
public class ProductBrandController {
private ProductBrandRepository productBrandRepository;

public ProductBrandController(ProductBrandRepository productBrandRepository) {
this.productBrandRepository = productBrandRepository;
}

@GetMapping("/all")
public List<ProductBrand> getAll() {
List<ProductBrand> product = this.productBrandRepository.findAll();

return product;
}

@GetMapping("/productbrand/{name}")
public List<ProductBrand> getByName(@PathVariable("name") String name) {
List<ProductBrand> product = this.productBrandRepository.findByName(name);

return product;
}

@PutMapping
public void insert(@RequestBody ProductBrand productBrand) {
this.productBrandRepository.insert(productBrand);
}

@PostMapping
public void update(@RequestBody ProductBrand productBrand) {
this.productBrandRepository.save(productBrand);
}

@DeleteMapping("/{id}")
public void delete(@PathVariable("id") ProductBrand id) {
this.productBrandRepository.delete(id);
}

@GetMapping("/{id}")
public Optional<ProductBrand> getById(@PathVariable("id") String id) {
Optional<ProductBrand> brand = this.productBrandRepository.findById(id);
return brand;

}

@GetMapping("/productBrand/{organic}")
public List<ProductBrand> getByOrganic(@PathVariable("organic") boolean organic) {
List<ProductBrand> brand = this.productBrandRepository.findByOrganic(organic);

return brand;
}

@GetMapping("/productBrand/{manufacturer}")
public List<ProductBrand> getByManufacturer(@PathVariable("manufacturer") String manufacturer) {
List<ProductBrand> brand = this.productBrandRepository.findByManufacturer(manufacturer);

return brand;
}

@GetMapping("/productBrand/{category}")
public List<ProductBrand> getByCategory(@PathVariable("category") String category) {
List<ProductBrand> brand = this.productBrandRepository.findByCategory(category);

return brand;
}

@GetMapping("/productBrand/{seasonal}")
public List<ProductBrand> getBySeasonal(@PathVariable("seasonal") boolean seasonal) {
List<ProductBrand> brand = this.productBrandRepository.findBySeasonal(seasonal);

return brand;
}

@GetMapping("/productBrand/{frozenGoods}")
public List<ProductBrand> getByFrozenGoods(@PathVariable("frozenGoods") boolean frozenGoods) {
List<ProductBrand> brand = this.productBrandRepository.findByFrozenGoods(frozenGoods);

return brand;
}

@GetMapping("/productBrand/{refrigeratedGoods}")
public List<ProductBrand> getByRefrigeratedGoods(@PathVariable("refrigeratedGoods") boolean refrigeratedGoods) {
List<ProductBrand> brand = this.productBrandRepository.findByRefrigeratedGoods(refrigeratedGoods);

return brand;
}

@GetMapping("/productBrand/{available}")
public List<ProductBrand> getByAvailable(@PathVariable("available") boolean available) {
List<ProductBrand> brand = this.productBrandRepository.findByAvailable(available);

return brand;
}


@GetMapping("/recommended")
public List<ProductBrand> getRecommended() {
final boolean isOrganic = true;
final boolean isSeasonal = true;

QProductBrand qBrand = new QProductBrand("ProductBrand");

BooleanExpression filterByOrganic = (qBrand.organicIndex).any().organic.gt(isOrganic);

BooleanExpression filterBySeasonal = (qBrand.seasonalIndex).any().seasonal.gt(isSeasonal);

List<ProductBrand> brand = (List<ProductBrand>) this.productBrandRepository
.findAll(filterByOrganic.and(filterBySeasonal));

return brand;
}

}


This is my repository



import java.util.List;

import org.springframework.data.mongodb.repository.MongoRepository;
import org.springframework.data.querydsl.QuerydslPredicateExecutor;
import org.springframework.stereotype.Repository;

@Repository
public interface ProductBrandRepository extends MongoRepository<ProductBrand, String>, QuerydslPredicateExecutor<ProductBrand> {

List<ProductBrand> findByName(String name);

List<ProductBrand> findByOrganic(boolean organic);

List<ProductBrand> findBySeasonal(boolean seasonal);

List<ProductBrand> findByFrozenGoods(boolean frozenGoods);

List<ProductBrand> findByRefrigeratedGoods(boolean refrigeratedGoods);

List<ProductBrand> findByAvailable(boolean available);

List<ProductBrand> findByCategory(String category);

List<ProductBrand> findByManufacturer(String manufacturer);

}


And this is my pom file



<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.BETAapp</groupId>
<artifactId>project</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>

<name>project</name>
<description>demo</description>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.6.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-elasticsearch</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-rest</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-groovy-templates</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mustache</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web-services</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.4.0-b180725.0427</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.mongodb.morphia/morphia -->
<dependency>
<groupId>org.mongodb.morphia</groupId>
<artifactId>morphia</artifactId>
<version>0.107</version>
</dependency>
<!-- https://mvnrepository.com/artifact/javax.persistence/javax.persistence-api -->
<dependency>
<groupId>javax.persistence</groupId>
<artifactId>javax.persistence-api</artifactId>
<version>2.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.querydsl/querydsl-apt -->
<dependency>
<groupId>com.querydsl</groupId>
<artifactId>querydsl-mongodb</artifactId>
<version>4.2.1</version>
<exclusions>
<exclusion>
<groupId>org.mongodb</groupId>
<artifactId>mongo-java-driver</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>com.mysema.maven</groupId>
<artifactId>apt-maven-plugin</artifactId>
<version>1.1.3</version>
<dependencies>
<dependency>
<groupId>com.querydsl</groupId>
<artifactId>querydsl-apt</artifactId>
<version>4.2.1</version>
</dependency>
</dependencies>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>process</goal>
</goals>
<configuration>
<outputDirectory>target/generated-sources/annotations</outputDirectory>
<processor>org.springframework.data.mongodb.repository.support.MongoAnnotationProcessor</processor>
<logOnlyOnError>true</logOnlyOnError>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>


</project>




Test set: project.StoreBased.ApplicationTests



Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 11.036 s <<< FAILURE! - in project.StoreBased.ApplicationTests
contextLoads(project.StoreBased.ApplicationTests) Time elapsed: 0.002 s <<< ERROR!
java.lang.IllegalStateException: Failed to load ApplicationContext
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'productBrandController' defined in file [C:UsersvinceDocumentsworkspace-spring-tool-suite-4-4.0.1.RELEASEproject(18.11.2018)targettest-classescomprojectprojectStoreBasedProductBrandController.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'productBrandRepository': Invocation of init method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.data.mongodb.repository.support.QuerydslMongoPredicateExecutor]: Constructor threw exception; nested exception is java.lang.IllegalArgumentException: Did not find a query class project.StoreBased.QProductBrand for domain class project.StoreBased.ProductBrand!
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'productBrandRepository': Invocation of init method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.data.mongodb.repository.support.QuerydslMongoPredicateExecutor]: Constructor threw exception; nested exception is java.lang.IllegalArgumentException: Did not find a query class project.StoreBased.QProductBrand for domain class project.project.StoreBased.ProductBrand!
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.data.mongodb.repository.support.QuerydslMongoPredicateExecutor]: Constructor threw exception; nested exception is java.lang.IllegalArgumentException: Did not find a query class project.StoreBased.QProductBrand for domain class project.StoreBased.ProductBrand!
Caused by: java.lang.IllegalArgumentException: Did not find a query class project.StoreBased.QProductBrand for domain class project.StoreBased.ProductBrand!
Caused by: java.lang.ClassNotFoundException: project.StoreBased.QProductBrand










share|improve this question































    2















    I created a maven project in sts and I am trying to create a war file for the project. I also have querydsl configured for my classes. One class is giving me a error response when I run maven install. ERROR: Error creating bean with name 'productBrandController' defined in file [C:UsersvinceDocumentsworkspace-spring-tool-suite-4-4.0.1.RELEASEprojecttargettest-classescomprojectprojectStoreBasedProductBrandController.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'productBrandRepository': Invocation of init method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.data.mongodb.repository.support.QuerydslMongoPredicateExecutor]: Constructor threw exception; nested exception is java.lang.IllegalArgumentException: Did not find a query class project.QProductBrand for domain class project.StoreBased.ProductBrand! I need help with my pom file (Not sure if javax.xml.bind might be the culprit) and I am also not sure if my output directory is correct (I already tried java instead of annotations as output). Much thanks for the help!



    This is the class



    import java.util.ArrayList;
    import java.util.List;

    import org.springframework.data.annotation.Id;
    import org.springframework.data.mongodb.core.index.IndexDirection;
    import org.springframework.data.mongodb.core.index.Indexed;
    import org.springframework.data.mongodb.core.mapping.Document;


    @Document(collection = "ProductBrand")
    public class ProductBrand {

    @Id
    private String id;
    private ProductsBasic basic;
    @Indexed(direction = IndexDirection.ASCENDING)
    private String name;
    @Indexed(direction = IndexDirection.ASCENDING)
    private String units;
    @Indexed(direction = IndexDirection.ASCENDING)
    private double price;
    @Indexed(direction = IndexDirection.ASCENDING)
    private double price100g;
    private String manufacturer;
    private List<Manufacturer> manufacturerIndex;
    private boolean organic;
    private List<Organic> organicIndex;
    private String category;
    private List<Category> categoryIndex;
    private String subCategory;
    private List<SubCategory> subCategoryIndex;
    private boolean seasonal;
    private List<Seasonal> seasonalIndex;
    private boolean frozenGoods;
    private List<FrozenGoods> frozenGoodsIndex;
    private boolean refrigeratedGoods;
    private List<RefrigeratedGoods> refrigeratedGoodsIndex;
    private boolean available;
    private List<Available> availableIndex;
    @Indexed(direction = IndexDirection.ASCENDING)
    private String store;
    private List<Store> storeIndex;

    // public ProductBrand() {
    // super();
    // }

    public ProductBrand() {
    this.setAvailableIndex(new ArrayList<>());
    this.setCategoryIndex(new ArrayList<>());
    this.setSubCategoryIndex(new ArrayList<>());
    this.setFrozenGoodsIndex(new ArrayList<>());
    this.setManufacturerIndex(new ArrayList<>());
    this.setOrganicIndex(new ArrayList<>());
    this.setRefrigeratedGoodsIndex(new ArrayList<>());
    this.setSeasonalIndex(new ArrayList<>());
    this.setStoreIndex(new ArrayList<>());
    }

    public ProductBrand(String id, ProductsBasic basic, String name, String units, double price, double price100g,
    String manufacturer, List<Manufacturer> manufacturerIndex, boolean organic, List<Organic> organicIndex,
    String category, List<Category> categoryIndex, String subCategory, List<SubCategory> subCategoryIndex,
    boolean seasonal, List<Seasonal> seasonalIndex, boolean frozenGoods, List<FrozenGoods> frozenGoodsIndex,
    boolean refrigeratedGoods, List<RefrigeratedGoods> refrigeratedGoodsIndex, boolean available,
    List<Available> availableIndex, String store, List<Store> storeIndex) {
    super();
    this.id = id;
    this.basic = basic;
    this.name = name;
    this.units = units;
    this.price = price;
    this.price100g = price100g;
    this.manufacturer = manufacturer;
    this.setManufacturerIndex(manufacturerIndex);
    this.organic = organic;
    this.setOrganicIndex(organicIndex);
    this.category = category;
    this.setCategoryIndex(categoryIndex);
    this.subCategory = subCategory;
    this.setSubCategoryIndex(subCategoryIndex);
    this.seasonal = seasonal;
    this.setSeasonalIndex(seasonalIndex);
    this.frozenGoods = frozenGoods;
    this.setFrozenGoodsIndex(frozenGoodsIndex);
    this.refrigeratedGoods = refrigeratedGoods;
    this.setRefrigeratedGoodsIndex(refrigeratedGoodsIndex);
    this.available = available;
    this.setAvailableIndex(availableIndex);
    this.store = store;
    this.setStoreIndex(storeIndex);
    }

    public String getManufacturer() {
    return manufacturer;
    }

    public void setManufacturer(String manufacturer) {
    this.manufacturer = manufacturer;
    }

    public boolean isOrganic() {
    return organic;
    }

    public void setOrganic(boolean organic) {
    this.organic = organic;
    }

    public String getCategory() {
    return category;
    }

    public void setCategory(String category) {
    this.category = category;
    }

    public String getSubCategory() {
    return subCategory;
    }

    public void setSubCategory(String subCategory) {
    this.subCategory = subCategory;
    }

    public boolean isSeasonal() {
    return seasonal;
    }

    public void setSeasonal(boolean seasonal) {
    this.seasonal = seasonal;
    }

    public boolean isFrozenGoods() {
    return frozenGoods;
    }

    public void setFrozenGoods(boolean frozenGoods) {
    this.frozenGoods = frozenGoods;
    }

    public boolean isRefrigeratedGoods() {
    return refrigeratedGoods;
    }

    public void setRefrigeratedGoods(boolean refrigeratedGoods) {
    this.refrigeratedGoods = refrigeratedGoods;
    }

    public boolean isAvailable() {
    return available;
    }

    public void setAvailable(boolean available) {
    this.available = available;
    }

    public void addProduktBrand(ProductBrand productBrand) {
    ProductBrand.add(productBrand);
    }

    public static void add(ProductBrand productBrand) {
    }

    public String getId() {
    return id;
    }

    public void setId(String id) {
    this.id = id;
    }

    public ProductsBasic getBasic() {
    return basic;
    }

    public void setBasic(ProductsBasic basic) {
    this.basic = basic;
    }

    public String getStore() {
    return store;
    }

    public void setStore(String store) {
    this.store = store;
    }

    public String getName() {
    return name;
    }

    public void setName(String name) {
    this.name = name;
    }

    public String getUnits() {
    return units;
    }

    public void setUnits(String units) {
    this.units = units;
    }

    public double getPrice() {
    return price;
    }

    public void setPrice(double price) {
    this.price = price;
    }

    public double getPrice100g() {
    return price100g;
    }

    public void setPrice100g(double price100g) {
    this.price100g = price100g;
    }

    public List<Manufacturer> getManufacturerIndex() {
    return manufacturerIndex;
    }

    public void setManufacturerIndex(List<Manufacturer> manufacturerIndex) {
    this.manufacturerIndex = manufacturerIndex;
    }

    public List<Organic> getOrganicIndex() {
    return organicIndex;
    }

    public void setOrganicIndex(List<Organic> organicIndex) {
    this.organicIndex = organicIndex;
    }

    public List<Category> getCategoryIndex() {
    return categoryIndex;
    }

    public void setCategoryIndex(List<Category> categoryIndex) {
    this.categoryIndex = categoryIndex;
    }

    public List<SubCategory> getSubCategoryIndex() {
    return subCategoryIndex;
    }

    public void setSubCategoryIndex(List<SubCategory> subCategoryIndex) {
    this.subCategoryIndex = subCategoryIndex;
    }

    public List<Seasonal> getSeasonalIndex() {
    return seasonalIndex;
    }

    public void setSeasonalIndex(List<Seasonal> seasonalIndex) {
    this.seasonalIndex = seasonalIndex;
    }

    public List<FrozenGoods> getFrozenGoodsIndex() {
    return frozenGoodsIndex;
    }

    public void setFrozenGoodsIndex(List<FrozenGoods> frozenGoodsIndex) {
    this.frozenGoodsIndex = frozenGoodsIndex;
    }

    public List<RefrigeratedGoods> getRefrigeratedGoodsIndex() {
    return refrigeratedGoodsIndex;
    }

    public void setRefrigeratedGoodsIndex(List<RefrigeratedGoods> refrigeratedGoodsIndex) {
    this.refrigeratedGoodsIndex = refrigeratedGoodsIndex;
    }

    public List<Available> getAvailableIndex() {
    return availableIndex;
    }

    public void setAvailableIndex(List<Available> availableIndex) {
    this.availableIndex = availableIndex;
    }

    public List<Store> getStoreIndex() {
    return storeIndex;
    }

    public void setStoreIndex(List<Store> storeIndex) {
    this.storeIndex = storeIndex;
    }

    }


    This is the controller of the class



    import java.util.List;
    import java.util.Optional;

    import org.springframework.web.bind.annotation.DeleteMapping;
    import org.springframework.web.bind.annotation.GetMapping;
    import org.springframework.web.bind.annotation.PathVariable;
    import org.springframework.web.bind.annotation.PostMapping;
    import org.springframework.web.bind.annotation.PutMapping;
    import org.springframework.web.bind.annotation.RequestBody;
    import org.springframework.web.bind.annotation.RequestMapping;
    import org.springframework.web.bind.annotation.RestController;

    import project.QProductBrand;
    import com.querydsl.core.types.dsl.BooleanExpression;


    @RestController
    @RequestMapping("/productbrand")
    public class ProductBrandController {
    private ProductBrandRepository productBrandRepository;

    public ProductBrandController(ProductBrandRepository productBrandRepository) {
    this.productBrandRepository = productBrandRepository;
    }

    @GetMapping("/all")
    public List<ProductBrand> getAll() {
    List<ProductBrand> product = this.productBrandRepository.findAll();

    return product;
    }

    @GetMapping("/productbrand/{name}")
    public List<ProductBrand> getByName(@PathVariable("name") String name) {
    List<ProductBrand> product = this.productBrandRepository.findByName(name);

    return product;
    }

    @PutMapping
    public void insert(@RequestBody ProductBrand productBrand) {
    this.productBrandRepository.insert(productBrand);
    }

    @PostMapping
    public void update(@RequestBody ProductBrand productBrand) {
    this.productBrandRepository.save(productBrand);
    }

    @DeleteMapping("/{id}")
    public void delete(@PathVariable("id") ProductBrand id) {
    this.productBrandRepository.delete(id);
    }

    @GetMapping("/{id}")
    public Optional<ProductBrand> getById(@PathVariable("id") String id) {
    Optional<ProductBrand> brand = this.productBrandRepository.findById(id);
    return brand;

    }

    @GetMapping("/productBrand/{organic}")
    public List<ProductBrand> getByOrganic(@PathVariable("organic") boolean organic) {
    List<ProductBrand> brand = this.productBrandRepository.findByOrganic(organic);

    return brand;
    }

    @GetMapping("/productBrand/{manufacturer}")
    public List<ProductBrand> getByManufacturer(@PathVariable("manufacturer") String manufacturer) {
    List<ProductBrand> brand = this.productBrandRepository.findByManufacturer(manufacturer);

    return brand;
    }

    @GetMapping("/productBrand/{category}")
    public List<ProductBrand> getByCategory(@PathVariable("category") String category) {
    List<ProductBrand> brand = this.productBrandRepository.findByCategory(category);

    return brand;
    }

    @GetMapping("/productBrand/{seasonal}")
    public List<ProductBrand> getBySeasonal(@PathVariable("seasonal") boolean seasonal) {
    List<ProductBrand> brand = this.productBrandRepository.findBySeasonal(seasonal);

    return brand;
    }

    @GetMapping("/productBrand/{frozenGoods}")
    public List<ProductBrand> getByFrozenGoods(@PathVariable("frozenGoods") boolean frozenGoods) {
    List<ProductBrand> brand = this.productBrandRepository.findByFrozenGoods(frozenGoods);

    return brand;
    }

    @GetMapping("/productBrand/{refrigeratedGoods}")
    public List<ProductBrand> getByRefrigeratedGoods(@PathVariable("refrigeratedGoods") boolean refrigeratedGoods) {
    List<ProductBrand> brand = this.productBrandRepository.findByRefrigeratedGoods(refrigeratedGoods);

    return brand;
    }

    @GetMapping("/productBrand/{available}")
    public List<ProductBrand> getByAvailable(@PathVariable("available") boolean available) {
    List<ProductBrand> brand = this.productBrandRepository.findByAvailable(available);

    return brand;
    }


    @GetMapping("/recommended")
    public List<ProductBrand> getRecommended() {
    final boolean isOrganic = true;
    final boolean isSeasonal = true;

    QProductBrand qBrand = new QProductBrand("ProductBrand");

    BooleanExpression filterByOrganic = (qBrand.organicIndex).any().organic.gt(isOrganic);

    BooleanExpression filterBySeasonal = (qBrand.seasonalIndex).any().seasonal.gt(isSeasonal);

    List<ProductBrand> brand = (List<ProductBrand>) this.productBrandRepository
    .findAll(filterByOrganic.and(filterBySeasonal));

    return brand;
    }

    }


    This is my repository



    import java.util.List;

    import org.springframework.data.mongodb.repository.MongoRepository;
    import org.springframework.data.querydsl.QuerydslPredicateExecutor;
    import org.springframework.stereotype.Repository;

    @Repository
    public interface ProductBrandRepository extends MongoRepository<ProductBrand, String>, QuerydslPredicateExecutor<ProductBrand> {

    List<ProductBrand> findByName(String name);

    List<ProductBrand> findByOrganic(boolean organic);

    List<ProductBrand> findBySeasonal(boolean seasonal);

    List<ProductBrand> findByFrozenGoods(boolean frozenGoods);

    List<ProductBrand> findByRefrigeratedGoods(boolean refrigeratedGoods);

    List<ProductBrand> findByAvailable(boolean available);

    List<ProductBrand> findByCategory(String category);

    List<ProductBrand> findByManufacturer(String manufacturer);

    }


    And this is my pom file



    <?xml version="1.0" encoding="UTF-8"?>
    <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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.BETAapp</groupId>
    <artifactId>project</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>war</packaging>

    <name>project</name>
    <description>demo</description>

    <parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.0.6.RELEASE</version>
    <relativePath /> <!-- lookup parent from repository -->
    </parent>

    <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <java.version>1.8</java.version>
    </properties>

    <dependencies>
    <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-data-elasticsearch</artifactId>
    </dependency>
    <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-data-mongodb</artifactId>
    </dependency>
    <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-data-rest</artifactId>
    </dependency>
    <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-groovy-templates</artifactId>
    </dependency>
    <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-mustache</artifactId>
    </dependency>
    <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-security</artifactId>
    </dependency>
    <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-thymeleaf</artifactId>
    </dependency>
    <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web-services</artifactId>
    </dependency>

    <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-devtools</artifactId>
    <scope>runtime</scope>
    </dependency>
    <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-tomcat</artifactId>
    <scope>provided</scope>
    </dependency>
    <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-test</artifactId>
    <scope>test</scope>
    </dependency>
    <dependency>
    <groupId>org.springframework.security</groupId>
    <artifactId>spring-security-test</artifactId>
    <scope>test</scope>
    </dependency>
    <dependency>
    <groupId>javax.xml.bind</groupId>
    <artifactId>jaxb-api</artifactId>
    <version>2.4.0-b180725.0427</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.mongodb.morphia/morphia -->
    <dependency>
    <groupId>org.mongodb.morphia</groupId>
    <artifactId>morphia</artifactId>
    <version>0.107</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/javax.persistence/javax.persistence-api -->
    <dependency>
    <groupId>javax.persistence</groupId>
    <artifactId>javax.persistence-api</artifactId>
    <version>2.2</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/com.querydsl/querydsl-apt -->
    <dependency>
    <groupId>com.querydsl</groupId>
    <artifactId>querydsl-mongodb</artifactId>
    <version>4.2.1</version>
    <exclusions>
    <exclusion>
    <groupId>org.mongodb</groupId>
    <artifactId>mongo-java-driver</artifactId>
    </exclusion>
    </exclusions>
    </dependency>
    </dependencies>

    <build>
    <plugins>
    <plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    </plugin>
    <plugin>
    <groupId>com.mysema.maven</groupId>
    <artifactId>apt-maven-plugin</artifactId>
    <version>1.1.3</version>
    <dependencies>
    <dependency>
    <groupId>com.querydsl</groupId>
    <artifactId>querydsl-apt</artifactId>
    <version>4.2.1</version>
    </dependency>
    </dependencies>
    <executions>
    <execution>
    <phase>generate-sources</phase>
    <goals>
    <goal>process</goal>
    </goals>
    <configuration>
    <outputDirectory>target/generated-sources/annotations</outputDirectory>
    <processor>org.springframework.data.mongodb.repository.support.MongoAnnotationProcessor</processor>
    <logOnlyOnError>true</logOnlyOnError>
    </configuration>
    </execution>
    </executions>
    </plugin>
    </plugins>
    </build>


    </project>




    Test set: project.StoreBased.ApplicationTests



    Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 11.036 s <<< FAILURE! - in project.StoreBased.ApplicationTests
    contextLoads(project.StoreBased.ApplicationTests) Time elapsed: 0.002 s <<< ERROR!
    java.lang.IllegalStateException: Failed to load ApplicationContext
    Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'productBrandController' defined in file [C:UsersvinceDocumentsworkspace-spring-tool-suite-4-4.0.1.RELEASEproject(18.11.2018)targettest-classescomprojectprojectStoreBasedProductBrandController.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'productBrandRepository': Invocation of init method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.data.mongodb.repository.support.QuerydslMongoPredicateExecutor]: Constructor threw exception; nested exception is java.lang.IllegalArgumentException: Did not find a query class project.StoreBased.QProductBrand for domain class project.StoreBased.ProductBrand!
    Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'productBrandRepository': Invocation of init method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.data.mongodb.repository.support.QuerydslMongoPredicateExecutor]: Constructor threw exception; nested exception is java.lang.IllegalArgumentException: Did not find a query class project.StoreBased.QProductBrand for domain class project.project.StoreBased.ProductBrand!
    Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.data.mongodb.repository.support.QuerydslMongoPredicateExecutor]: Constructor threw exception; nested exception is java.lang.IllegalArgumentException: Did not find a query class project.StoreBased.QProductBrand for domain class project.StoreBased.ProductBrand!
    Caused by: java.lang.IllegalArgumentException: Did not find a query class project.StoreBased.QProductBrand for domain class project.StoreBased.ProductBrand!
    Caused by: java.lang.ClassNotFoundException: project.StoreBased.QProductBrand










    share|improve this question



























      2












      2








      2








      I created a maven project in sts and I am trying to create a war file for the project. I also have querydsl configured for my classes. One class is giving me a error response when I run maven install. ERROR: Error creating bean with name 'productBrandController' defined in file [C:UsersvinceDocumentsworkspace-spring-tool-suite-4-4.0.1.RELEASEprojecttargettest-classescomprojectprojectStoreBasedProductBrandController.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'productBrandRepository': Invocation of init method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.data.mongodb.repository.support.QuerydslMongoPredicateExecutor]: Constructor threw exception; nested exception is java.lang.IllegalArgumentException: Did not find a query class project.QProductBrand for domain class project.StoreBased.ProductBrand! I need help with my pom file (Not sure if javax.xml.bind might be the culprit) and I am also not sure if my output directory is correct (I already tried java instead of annotations as output). Much thanks for the help!



      This is the class



      import java.util.ArrayList;
      import java.util.List;

      import org.springframework.data.annotation.Id;
      import org.springframework.data.mongodb.core.index.IndexDirection;
      import org.springframework.data.mongodb.core.index.Indexed;
      import org.springframework.data.mongodb.core.mapping.Document;


      @Document(collection = "ProductBrand")
      public class ProductBrand {

      @Id
      private String id;
      private ProductsBasic basic;
      @Indexed(direction = IndexDirection.ASCENDING)
      private String name;
      @Indexed(direction = IndexDirection.ASCENDING)
      private String units;
      @Indexed(direction = IndexDirection.ASCENDING)
      private double price;
      @Indexed(direction = IndexDirection.ASCENDING)
      private double price100g;
      private String manufacturer;
      private List<Manufacturer> manufacturerIndex;
      private boolean organic;
      private List<Organic> organicIndex;
      private String category;
      private List<Category> categoryIndex;
      private String subCategory;
      private List<SubCategory> subCategoryIndex;
      private boolean seasonal;
      private List<Seasonal> seasonalIndex;
      private boolean frozenGoods;
      private List<FrozenGoods> frozenGoodsIndex;
      private boolean refrigeratedGoods;
      private List<RefrigeratedGoods> refrigeratedGoodsIndex;
      private boolean available;
      private List<Available> availableIndex;
      @Indexed(direction = IndexDirection.ASCENDING)
      private String store;
      private List<Store> storeIndex;

      // public ProductBrand() {
      // super();
      // }

      public ProductBrand() {
      this.setAvailableIndex(new ArrayList<>());
      this.setCategoryIndex(new ArrayList<>());
      this.setSubCategoryIndex(new ArrayList<>());
      this.setFrozenGoodsIndex(new ArrayList<>());
      this.setManufacturerIndex(new ArrayList<>());
      this.setOrganicIndex(new ArrayList<>());
      this.setRefrigeratedGoodsIndex(new ArrayList<>());
      this.setSeasonalIndex(new ArrayList<>());
      this.setStoreIndex(new ArrayList<>());
      }

      public ProductBrand(String id, ProductsBasic basic, String name, String units, double price, double price100g,
      String manufacturer, List<Manufacturer> manufacturerIndex, boolean organic, List<Organic> organicIndex,
      String category, List<Category> categoryIndex, String subCategory, List<SubCategory> subCategoryIndex,
      boolean seasonal, List<Seasonal> seasonalIndex, boolean frozenGoods, List<FrozenGoods> frozenGoodsIndex,
      boolean refrigeratedGoods, List<RefrigeratedGoods> refrigeratedGoodsIndex, boolean available,
      List<Available> availableIndex, String store, List<Store> storeIndex) {
      super();
      this.id = id;
      this.basic = basic;
      this.name = name;
      this.units = units;
      this.price = price;
      this.price100g = price100g;
      this.manufacturer = manufacturer;
      this.setManufacturerIndex(manufacturerIndex);
      this.organic = organic;
      this.setOrganicIndex(organicIndex);
      this.category = category;
      this.setCategoryIndex(categoryIndex);
      this.subCategory = subCategory;
      this.setSubCategoryIndex(subCategoryIndex);
      this.seasonal = seasonal;
      this.setSeasonalIndex(seasonalIndex);
      this.frozenGoods = frozenGoods;
      this.setFrozenGoodsIndex(frozenGoodsIndex);
      this.refrigeratedGoods = refrigeratedGoods;
      this.setRefrigeratedGoodsIndex(refrigeratedGoodsIndex);
      this.available = available;
      this.setAvailableIndex(availableIndex);
      this.store = store;
      this.setStoreIndex(storeIndex);
      }

      public String getManufacturer() {
      return manufacturer;
      }

      public void setManufacturer(String manufacturer) {
      this.manufacturer = manufacturer;
      }

      public boolean isOrganic() {
      return organic;
      }

      public void setOrganic(boolean organic) {
      this.organic = organic;
      }

      public String getCategory() {
      return category;
      }

      public void setCategory(String category) {
      this.category = category;
      }

      public String getSubCategory() {
      return subCategory;
      }

      public void setSubCategory(String subCategory) {
      this.subCategory = subCategory;
      }

      public boolean isSeasonal() {
      return seasonal;
      }

      public void setSeasonal(boolean seasonal) {
      this.seasonal = seasonal;
      }

      public boolean isFrozenGoods() {
      return frozenGoods;
      }

      public void setFrozenGoods(boolean frozenGoods) {
      this.frozenGoods = frozenGoods;
      }

      public boolean isRefrigeratedGoods() {
      return refrigeratedGoods;
      }

      public void setRefrigeratedGoods(boolean refrigeratedGoods) {
      this.refrigeratedGoods = refrigeratedGoods;
      }

      public boolean isAvailable() {
      return available;
      }

      public void setAvailable(boolean available) {
      this.available = available;
      }

      public void addProduktBrand(ProductBrand productBrand) {
      ProductBrand.add(productBrand);
      }

      public static void add(ProductBrand productBrand) {
      }

      public String getId() {
      return id;
      }

      public void setId(String id) {
      this.id = id;
      }

      public ProductsBasic getBasic() {
      return basic;
      }

      public void setBasic(ProductsBasic basic) {
      this.basic = basic;
      }

      public String getStore() {
      return store;
      }

      public void setStore(String store) {
      this.store = store;
      }

      public String getName() {
      return name;
      }

      public void setName(String name) {
      this.name = name;
      }

      public String getUnits() {
      return units;
      }

      public void setUnits(String units) {
      this.units = units;
      }

      public double getPrice() {
      return price;
      }

      public void setPrice(double price) {
      this.price = price;
      }

      public double getPrice100g() {
      return price100g;
      }

      public void setPrice100g(double price100g) {
      this.price100g = price100g;
      }

      public List<Manufacturer> getManufacturerIndex() {
      return manufacturerIndex;
      }

      public void setManufacturerIndex(List<Manufacturer> manufacturerIndex) {
      this.manufacturerIndex = manufacturerIndex;
      }

      public List<Organic> getOrganicIndex() {
      return organicIndex;
      }

      public void setOrganicIndex(List<Organic> organicIndex) {
      this.organicIndex = organicIndex;
      }

      public List<Category> getCategoryIndex() {
      return categoryIndex;
      }

      public void setCategoryIndex(List<Category> categoryIndex) {
      this.categoryIndex = categoryIndex;
      }

      public List<SubCategory> getSubCategoryIndex() {
      return subCategoryIndex;
      }

      public void setSubCategoryIndex(List<SubCategory> subCategoryIndex) {
      this.subCategoryIndex = subCategoryIndex;
      }

      public List<Seasonal> getSeasonalIndex() {
      return seasonalIndex;
      }

      public void setSeasonalIndex(List<Seasonal> seasonalIndex) {
      this.seasonalIndex = seasonalIndex;
      }

      public List<FrozenGoods> getFrozenGoodsIndex() {
      return frozenGoodsIndex;
      }

      public void setFrozenGoodsIndex(List<FrozenGoods> frozenGoodsIndex) {
      this.frozenGoodsIndex = frozenGoodsIndex;
      }

      public List<RefrigeratedGoods> getRefrigeratedGoodsIndex() {
      return refrigeratedGoodsIndex;
      }

      public void setRefrigeratedGoodsIndex(List<RefrigeratedGoods> refrigeratedGoodsIndex) {
      this.refrigeratedGoodsIndex = refrigeratedGoodsIndex;
      }

      public List<Available> getAvailableIndex() {
      return availableIndex;
      }

      public void setAvailableIndex(List<Available> availableIndex) {
      this.availableIndex = availableIndex;
      }

      public List<Store> getStoreIndex() {
      return storeIndex;
      }

      public void setStoreIndex(List<Store> storeIndex) {
      this.storeIndex = storeIndex;
      }

      }


      This is the controller of the class



      import java.util.List;
      import java.util.Optional;

      import org.springframework.web.bind.annotation.DeleteMapping;
      import org.springframework.web.bind.annotation.GetMapping;
      import org.springframework.web.bind.annotation.PathVariable;
      import org.springframework.web.bind.annotation.PostMapping;
      import org.springframework.web.bind.annotation.PutMapping;
      import org.springframework.web.bind.annotation.RequestBody;
      import org.springframework.web.bind.annotation.RequestMapping;
      import org.springframework.web.bind.annotation.RestController;

      import project.QProductBrand;
      import com.querydsl.core.types.dsl.BooleanExpression;


      @RestController
      @RequestMapping("/productbrand")
      public class ProductBrandController {
      private ProductBrandRepository productBrandRepository;

      public ProductBrandController(ProductBrandRepository productBrandRepository) {
      this.productBrandRepository = productBrandRepository;
      }

      @GetMapping("/all")
      public List<ProductBrand> getAll() {
      List<ProductBrand> product = this.productBrandRepository.findAll();

      return product;
      }

      @GetMapping("/productbrand/{name}")
      public List<ProductBrand> getByName(@PathVariable("name") String name) {
      List<ProductBrand> product = this.productBrandRepository.findByName(name);

      return product;
      }

      @PutMapping
      public void insert(@RequestBody ProductBrand productBrand) {
      this.productBrandRepository.insert(productBrand);
      }

      @PostMapping
      public void update(@RequestBody ProductBrand productBrand) {
      this.productBrandRepository.save(productBrand);
      }

      @DeleteMapping("/{id}")
      public void delete(@PathVariable("id") ProductBrand id) {
      this.productBrandRepository.delete(id);
      }

      @GetMapping("/{id}")
      public Optional<ProductBrand> getById(@PathVariable("id") String id) {
      Optional<ProductBrand> brand = this.productBrandRepository.findById(id);
      return brand;

      }

      @GetMapping("/productBrand/{organic}")
      public List<ProductBrand> getByOrganic(@PathVariable("organic") boolean organic) {
      List<ProductBrand> brand = this.productBrandRepository.findByOrganic(organic);

      return brand;
      }

      @GetMapping("/productBrand/{manufacturer}")
      public List<ProductBrand> getByManufacturer(@PathVariable("manufacturer") String manufacturer) {
      List<ProductBrand> brand = this.productBrandRepository.findByManufacturer(manufacturer);

      return brand;
      }

      @GetMapping("/productBrand/{category}")
      public List<ProductBrand> getByCategory(@PathVariable("category") String category) {
      List<ProductBrand> brand = this.productBrandRepository.findByCategory(category);

      return brand;
      }

      @GetMapping("/productBrand/{seasonal}")
      public List<ProductBrand> getBySeasonal(@PathVariable("seasonal") boolean seasonal) {
      List<ProductBrand> brand = this.productBrandRepository.findBySeasonal(seasonal);

      return brand;
      }

      @GetMapping("/productBrand/{frozenGoods}")
      public List<ProductBrand> getByFrozenGoods(@PathVariable("frozenGoods") boolean frozenGoods) {
      List<ProductBrand> brand = this.productBrandRepository.findByFrozenGoods(frozenGoods);

      return brand;
      }

      @GetMapping("/productBrand/{refrigeratedGoods}")
      public List<ProductBrand> getByRefrigeratedGoods(@PathVariable("refrigeratedGoods") boolean refrigeratedGoods) {
      List<ProductBrand> brand = this.productBrandRepository.findByRefrigeratedGoods(refrigeratedGoods);

      return brand;
      }

      @GetMapping("/productBrand/{available}")
      public List<ProductBrand> getByAvailable(@PathVariable("available") boolean available) {
      List<ProductBrand> brand = this.productBrandRepository.findByAvailable(available);

      return brand;
      }


      @GetMapping("/recommended")
      public List<ProductBrand> getRecommended() {
      final boolean isOrganic = true;
      final boolean isSeasonal = true;

      QProductBrand qBrand = new QProductBrand("ProductBrand");

      BooleanExpression filterByOrganic = (qBrand.organicIndex).any().organic.gt(isOrganic);

      BooleanExpression filterBySeasonal = (qBrand.seasonalIndex).any().seasonal.gt(isSeasonal);

      List<ProductBrand> brand = (List<ProductBrand>) this.productBrandRepository
      .findAll(filterByOrganic.and(filterBySeasonal));

      return brand;
      }

      }


      This is my repository



      import java.util.List;

      import org.springframework.data.mongodb.repository.MongoRepository;
      import org.springframework.data.querydsl.QuerydslPredicateExecutor;
      import org.springframework.stereotype.Repository;

      @Repository
      public interface ProductBrandRepository extends MongoRepository<ProductBrand, String>, QuerydslPredicateExecutor<ProductBrand> {

      List<ProductBrand> findByName(String name);

      List<ProductBrand> findByOrganic(boolean organic);

      List<ProductBrand> findBySeasonal(boolean seasonal);

      List<ProductBrand> findByFrozenGoods(boolean frozenGoods);

      List<ProductBrand> findByRefrigeratedGoods(boolean refrigeratedGoods);

      List<ProductBrand> findByAvailable(boolean available);

      List<ProductBrand> findByCategory(String category);

      List<ProductBrand> findByManufacturer(String manufacturer);

      }


      And this is my pom file



      <?xml version="1.0" encoding="UTF-8"?>
      <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/xsd/maven-4.0.0.xsd">
      <modelVersion>4.0.0</modelVersion>

      <groupId>com.BETAapp</groupId>
      <artifactId>project</artifactId>
      <version>0.0.1-SNAPSHOT</version>
      <packaging>war</packaging>

      <name>project</name>
      <description>demo</description>

      <parent>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-parent</artifactId>
      <version>2.0.6.RELEASE</version>
      <relativePath /> <!-- lookup parent from repository -->
      </parent>

      <properties>
      <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
      <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
      <java.version>1.8</java.version>
      </properties>

      <dependencies>
      <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-data-elasticsearch</artifactId>
      </dependency>
      <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-data-mongodb</artifactId>
      </dependency>
      <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-data-rest</artifactId>
      </dependency>
      <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-groovy-templates</artifactId>
      </dependency>
      <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-mustache</artifactId>
      </dependency>
      <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-security</artifactId>
      </dependency>
      <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-thymeleaf</artifactId>
      </dependency>
      <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-web</artifactId>
      </dependency>
      <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-web-services</artifactId>
      </dependency>

      <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-devtools</artifactId>
      <scope>runtime</scope>
      </dependency>
      <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-tomcat</artifactId>
      <scope>provided</scope>
      </dependency>
      <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-test</artifactId>
      <scope>test</scope>
      </dependency>
      <dependency>
      <groupId>org.springframework.security</groupId>
      <artifactId>spring-security-test</artifactId>
      <scope>test</scope>
      </dependency>
      <dependency>
      <groupId>javax.xml.bind</groupId>
      <artifactId>jaxb-api</artifactId>
      <version>2.4.0-b180725.0427</version>
      </dependency>
      <!-- https://mvnrepository.com/artifact/org.mongodb.morphia/morphia -->
      <dependency>
      <groupId>org.mongodb.morphia</groupId>
      <artifactId>morphia</artifactId>
      <version>0.107</version>
      </dependency>
      <!-- https://mvnrepository.com/artifact/javax.persistence/javax.persistence-api -->
      <dependency>
      <groupId>javax.persistence</groupId>
      <artifactId>javax.persistence-api</artifactId>
      <version>2.2</version>
      </dependency>
      <!-- https://mvnrepository.com/artifact/com.querydsl/querydsl-apt -->
      <dependency>
      <groupId>com.querydsl</groupId>
      <artifactId>querydsl-mongodb</artifactId>
      <version>4.2.1</version>
      <exclusions>
      <exclusion>
      <groupId>org.mongodb</groupId>
      <artifactId>mongo-java-driver</artifactId>
      </exclusion>
      </exclusions>
      </dependency>
      </dependencies>

      <build>
      <plugins>
      <plugin>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-maven-plugin</artifactId>
      </plugin>
      <plugin>
      <groupId>com.mysema.maven</groupId>
      <artifactId>apt-maven-plugin</artifactId>
      <version>1.1.3</version>
      <dependencies>
      <dependency>
      <groupId>com.querydsl</groupId>
      <artifactId>querydsl-apt</artifactId>
      <version>4.2.1</version>
      </dependency>
      </dependencies>
      <executions>
      <execution>
      <phase>generate-sources</phase>
      <goals>
      <goal>process</goal>
      </goals>
      <configuration>
      <outputDirectory>target/generated-sources/annotations</outputDirectory>
      <processor>org.springframework.data.mongodb.repository.support.MongoAnnotationProcessor</processor>
      <logOnlyOnError>true</logOnlyOnError>
      </configuration>
      </execution>
      </executions>
      </plugin>
      </plugins>
      </build>


      </project>




      Test set: project.StoreBased.ApplicationTests



      Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 11.036 s <<< FAILURE! - in project.StoreBased.ApplicationTests
      contextLoads(project.StoreBased.ApplicationTests) Time elapsed: 0.002 s <<< ERROR!
      java.lang.IllegalStateException: Failed to load ApplicationContext
      Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'productBrandController' defined in file [C:UsersvinceDocumentsworkspace-spring-tool-suite-4-4.0.1.RELEASEproject(18.11.2018)targettest-classescomprojectprojectStoreBasedProductBrandController.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'productBrandRepository': Invocation of init method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.data.mongodb.repository.support.QuerydslMongoPredicateExecutor]: Constructor threw exception; nested exception is java.lang.IllegalArgumentException: Did not find a query class project.StoreBased.QProductBrand for domain class project.StoreBased.ProductBrand!
      Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'productBrandRepository': Invocation of init method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.data.mongodb.repository.support.QuerydslMongoPredicateExecutor]: Constructor threw exception; nested exception is java.lang.IllegalArgumentException: Did not find a query class project.StoreBased.QProductBrand for domain class project.project.StoreBased.ProductBrand!
      Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.data.mongodb.repository.support.QuerydslMongoPredicateExecutor]: Constructor threw exception; nested exception is java.lang.IllegalArgumentException: Did not find a query class project.StoreBased.QProductBrand for domain class project.StoreBased.ProductBrand!
      Caused by: java.lang.IllegalArgumentException: Did not find a query class project.StoreBased.QProductBrand for domain class project.StoreBased.ProductBrand!
      Caused by: java.lang.ClassNotFoundException: project.StoreBased.QProductBrand










      share|improve this question
















      I created a maven project in sts and I am trying to create a war file for the project. I also have querydsl configured for my classes. One class is giving me a error response when I run maven install. ERROR: Error creating bean with name 'productBrandController' defined in file [C:UsersvinceDocumentsworkspace-spring-tool-suite-4-4.0.1.RELEASEprojecttargettest-classescomprojectprojectStoreBasedProductBrandController.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'productBrandRepository': Invocation of init method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.data.mongodb.repository.support.QuerydslMongoPredicateExecutor]: Constructor threw exception; nested exception is java.lang.IllegalArgumentException: Did not find a query class project.QProductBrand for domain class project.StoreBased.ProductBrand! I need help with my pom file (Not sure if javax.xml.bind might be the culprit) and I am also not sure if my output directory is correct (I already tried java instead of annotations as output). Much thanks for the help!



      This is the class



      import java.util.ArrayList;
      import java.util.List;

      import org.springframework.data.annotation.Id;
      import org.springframework.data.mongodb.core.index.IndexDirection;
      import org.springframework.data.mongodb.core.index.Indexed;
      import org.springframework.data.mongodb.core.mapping.Document;


      @Document(collection = "ProductBrand")
      public class ProductBrand {

      @Id
      private String id;
      private ProductsBasic basic;
      @Indexed(direction = IndexDirection.ASCENDING)
      private String name;
      @Indexed(direction = IndexDirection.ASCENDING)
      private String units;
      @Indexed(direction = IndexDirection.ASCENDING)
      private double price;
      @Indexed(direction = IndexDirection.ASCENDING)
      private double price100g;
      private String manufacturer;
      private List<Manufacturer> manufacturerIndex;
      private boolean organic;
      private List<Organic> organicIndex;
      private String category;
      private List<Category> categoryIndex;
      private String subCategory;
      private List<SubCategory> subCategoryIndex;
      private boolean seasonal;
      private List<Seasonal> seasonalIndex;
      private boolean frozenGoods;
      private List<FrozenGoods> frozenGoodsIndex;
      private boolean refrigeratedGoods;
      private List<RefrigeratedGoods> refrigeratedGoodsIndex;
      private boolean available;
      private List<Available> availableIndex;
      @Indexed(direction = IndexDirection.ASCENDING)
      private String store;
      private List<Store> storeIndex;

      // public ProductBrand() {
      // super();
      // }

      public ProductBrand() {
      this.setAvailableIndex(new ArrayList<>());
      this.setCategoryIndex(new ArrayList<>());
      this.setSubCategoryIndex(new ArrayList<>());
      this.setFrozenGoodsIndex(new ArrayList<>());
      this.setManufacturerIndex(new ArrayList<>());
      this.setOrganicIndex(new ArrayList<>());
      this.setRefrigeratedGoodsIndex(new ArrayList<>());
      this.setSeasonalIndex(new ArrayList<>());
      this.setStoreIndex(new ArrayList<>());
      }

      public ProductBrand(String id, ProductsBasic basic, String name, String units, double price, double price100g,
      String manufacturer, List<Manufacturer> manufacturerIndex, boolean organic, List<Organic> organicIndex,
      String category, List<Category> categoryIndex, String subCategory, List<SubCategory> subCategoryIndex,
      boolean seasonal, List<Seasonal> seasonalIndex, boolean frozenGoods, List<FrozenGoods> frozenGoodsIndex,
      boolean refrigeratedGoods, List<RefrigeratedGoods> refrigeratedGoodsIndex, boolean available,
      List<Available> availableIndex, String store, List<Store> storeIndex) {
      super();
      this.id = id;
      this.basic = basic;
      this.name = name;
      this.units = units;
      this.price = price;
      this.price100g = price100g;
      this.manufacturer = manufacturer;
      this.setManufacturerIndex(manufacturerIndex);
      this.organic = organic;
      this.setOrganicIndex(organicIndex);
      this.category = category;
      this.setCategoryIndex(categoryIndex);
      this.subCategory = subCategory;
      this.setSubCategoryIndex(subCategoryIndex);
      this.seasonal = seasonal;
      this.setSeasonalIndex(seasonalIndex);
      this.frozenGoods = frozenGoods;
      this.setFrozenGoodsIndex(frozenGoodsIndex);
      this.refrigeratedGoods = refrigeratedGoods;
      this.setRefrigeratedGoodsIndex(refrigeratedGoodsIndex);
      this.available = available;
      this.setAvailableIndex(availableIndex);
      this.store = store;
      this.setStoreIndex(storeIndex);
      }

      public String getManufacturer() {
      return manufacturer;
      }

      public void setManufacturer(String manufacturer) {
      this.manufacturer = manufacturer;
      }

      public boolean isOrganic() {
      return organic;
      }

      public void setOrganic(boolean organic) {
      this.organic = organic;
      }

      public String getCategory() {
      return category;
      }

      public void setCategory(String category) {
      this.category = category;
      }

      public String getSubCategory() {
      return subCategory;
      }

      public void setSubCategory(String subCategory) {
      this.subCategory = subCategory;
      }

      public boolean isSeasonal() {
      return seasonal;
      }

      public void setSeasonal(boolean seasonal) {
      this.seasonal = seasonal;
      }

      public boolean isFrozenGoods() {
      return frozenGoods;
      }

      public void setFrozenGoods(boolean frozenGoods) {
      this.frozenGoods = frozenGoods;
      }

      public boolean isRefrigeratedGoods() {
      return refrigeratedGoods;
      }

      public void setRefrigeratedGoods(boolean refrigeratedGoods) {
      this.refrigeratedGoods = refrigeratedGoods;
      }

      public boolean isAvailable() {
      return available;
      }

      public void setAvailable(boolean available) {
      this.available = available;
      }

      public void addProduktBrand(ProductBrand productBrand) {
      ProductBrand.add(productBrand);
      }

      public static void add(ProductBrand productBrand) {
      }

      public String getId() {
      return id;
      }

      public void setId(String id) {
      this.id = id;
      }

      public ProductsBasic getBasic() {
      return basic;
      }

      public void setBasic(ProductsBasic basic) {
      this.basic = basic;
      }

      public String getStore() {
      return store;
      }

      public void setStore(String store) {
      this.store = store;
      }

      public String getName() {
      return name;
      }

      public void setName(String name) {
      this.name = name;
      }

      public String getUnits() {
      return units;
      }

      public void setUnits(String units) {
      this.units = units;
      }

      public double getPrice() {
      return price;
      }

      public void setPrice(double price) {
      this.price = price;
      }

      public double getPrice100g() {
      return price100g;
      }

      public void setPrice100g(double price100g) {
      this.price100g = price100g;
      }

      public List<Manufacturer> getManufacturerIndex() {
      return manufacturerIndex;
      }

      public void setManufacturerIndex(List<Manufacturer> manufacturerIndex) {
      this.manufacturerIndex = manufacturerIndex;
      }

      public List<Organic> getOrganicIndex() {
      return organicIndex;
      }

      public void setOrganicIndex(List<Organic> organicIndex) {
      this.organicIndex = organicIndex;
      }

      public List<Category> getCategoryIndex() {
      return categoryIndex;
      }

      public void setCategoryIndex(List<Category> categoryIndex) {
      this.categoryIndex = categoryIndex;
      }

      public List<SubCategory> getSubCategoryIndex() {
      return subCategoryIndex;
      }

      public void setSubCategoryIndex(List<SubCategory> subCategoryIndex) {
      this.subCategoryIndex = subCategoryIndex;
      }

      public List<Seasonal> getSeasonalIndex() {
      return seasonalIndex;
      }

      public void setSeasonalIndex(List<Seasonal> seasonalIndex) {
      this.seasonalIndex = seasonalIndex;
      }

      public List<FrozenGoods> getFrozenGoodsIndex() {
      return frozenGoodsIndex;
      }

      public void setFrozenGoodsIndex(List<FrozenGoods> frozenGoodsIndex) {
      this.frozenGoodsIndex = frozenGoodsIndex;
      }

      public List<RefrigeratedGoods> getRefrigeratedGoodsIndex() {
      return refrigeratedGoodsIndex;
      }

      public void setRefrigeratedGoodsIndex(List<RefrigeratedGoods> refrigeratedGoodsIndex) {
      this.refrigeratedGoodsIndex = refrigeratedGoodsIndex;
      }

      public List<Available> getAvailableIndex() {
      return availableIndex;
      }

      public void setAvailableIndex(List<Available> availableIndex) {
      this.availableIndex = availableIndex;
      }

      public List<Store> getStoreIndex() {
      return storeIndex;
      }

      public void setStoreIndex(List<Store> storeIndex) {
      this.storeIndex = storeIndex;
      }

      }


      This is the controller of the class



      import java.util.List;
      import java.util.Optional;

      import org.springframework.web.bind.annotation.DeleteMapping;
      import org.springframework.web.bind.annotation.GetMapping;
      import org.springframework.web.bind.annotation.PathVariable;
      import org.springframework.web.bind.annotation.PostMapping;
      import org.springframework.web.bind.annotation.PutMapping;
      import org.springframework.web.bind.annotation.RequestBody;
      import org.springframework.web.bind.annotation.RequestMapping;
      import org.springframework.web.bind.annotation.RestController;

      import project.QProductBrand;
      import com.querydsl.core.types.dsl.BooleanExpression;


      @RestController
      @RequestMapping("/productbrand")
      public class ProductBrandController {
      private ProductBrandRepository productBrandRepository;

      public ProductBrandController(ProductBrandRepository productBrandRepository) {
      this.productBrandRepository = productBrandRepository;
      }

      @GetMapping("/all")
      public List<ProductBrand> getAll() {
      List<ProductBrand> product = this.productBrandRepository.findAll();

      return product;
      }

      @GetMapping("/productbrand/{name}")
      public List<ProductBrand> getByName(@PathVariable("name") String name) {
      List<ProductBrand> product = this.productBrandRepository.findByName(name);

      return product;
      }

      @PutMapping
      public void insert(@RequestBody ProductBrand productBrand) {
      this.productBrandRepository.insert(productBrand);
      }

      @PostMapping
      public void update(@RequestBody ProductBrand productBrand) {
      this.productBrandRepository.save(productBrand);
      }

      @DeleteMapping("/{id}")
      public void delete(@PathVariable("id") ProductBrand id) {
      this.productBrandRepository.delete(id);
      }

      @GetMapping("/{id}")
      public Optional<ProductBrand> getById(@PathVariable("id") String id) {
      Optional<ProductBrand> brand = this.productBrandRepository.findById(id);
      return brand;

      }

      @GetMapping("/productBrand/{organic}")
      public List<ProductBrand> getByOrganic(@PathVariable("organic") boolean organic) {
      List<ProductBrand> brand = this.productBrandRepository.findByOrganic(organic);

      return brand;
      }

      @GetMapping("/productBrand/{manufacturer}")
      public List<ProductBrand> getByManufacturer(@PathVariable("manufacturer") String manufacturer) {
      List<ProductBrand> brand = this.productBrandRepository.findByManufacturer(manufacturer);

      return brand;
      }

      @GetMapping("/productBrand/{category}")
      public List<ProductBrand> getByCategory(@PathVariable("category") String category) {
      List<ProductBrand> brand = this.productBrandRepository.findByCategory(category);

      return brand;
      }

      @GetMapping("/productBrand/{seasonal}")
      public List<ProductBrand> getBySeasonal(@PathVariable("seasonal") boolean seasonal) {
      List<ProductBrand> brand = this.productBrandRepository.findBySeasonal(seasonal);

      return brand;
      }

      @GetMapping("/productBrand/{frozenGoods}")
      public List<ProductBrand> getByFrozenGoods(@PathVariable("frozenGoods") boolean frozenGoods) {
      List<ProductBrand> brand = this.productBrandRepository.findByFrozenGoods(frozenGoods);

      return brand;
      }

      @GetMapping("/productBrand/{refrigeratedGoods}")
      public List<ProductBrand> getByRefrigeratedGoods(@PathVariable("refrigeratedGoods") boolean refrigeratedGoods) {
      List<ProductBrand> brand = this.productBrandRepository.findByRefrigeratedGoods(refrigeratedGoods);

      return brand;
      }

      @GetMapping("/productBrand/{available}")
      public List<ProductBrand> getByAvailable(@PathVariable("available") boolean available) {
      List<ProductBrand> brand = this.productBrandRepository.findByAvailable(available);

      return brand;
      }


      @GetMapping("/recommended")
      public List<ProductBrand> getRecommended() {
      final boolean isOrganic = true;
      final boolean isSeasonal = true;

      QProductBrand qBrand = new QProductBrand("ProductBrand");

      BooleanExpression filterByOrganic = (qBrand.organicIndex).any().organic.gt(isOrganic);

      BooleanExpression filterBySeasonal = (qBrand.seasonalIndex).any().seasonal.gt(isSeasonal);

      List<ProductBrand> brand = (List<ProductBrand>) this.productBrandRepository
      .findAll(filterByOrganic.and(filterBySeasonal));

      return brand;
      }

      }


      This is my repository



      import java.util.List;

      import org.springframework.data.mongodb.repository.MongoRepository;
      import org.springframework.data.querydsl.QuerydslPredicateExecutor;
      import org.springframework.stereotype.Repository;

      @Repository
      public interface ProductBrandRepository extends MongoRepository<ProductBrand, String>, QuerydslPredicateExecutor<ProductBrand> {

      List<ProductBrand> findByName(String name);

      List<ProductBrand> findByOrganic(boolean organic);

      List<ProductBrand> findBySeasonal(boolean seasonal);

      List<ProductBrand> findByFrozenGoods(boolean frozenGoods);

      List<ProductBrand> findByRefrigeratedGoods(boolean refrigeratedGoods);

      List<ProductBrand> findByAvailable(boolean available);

      List<ProductBrand> findByCategory(String category);

      List<ProductBrand> findByManufacturer(String manufacturer);

      }


      And this is my pom file



      <?xml version="1.0" encoding="UTF-8"?>
      <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/xsd/maven-4.0.0.xsd">
      <modelVersion>4.0.0</modelVersion>

      <groupId>com.BETAapp</groupId>
      <artifactId>project</artifactId>
      <version>0.0.1-SNAPSHOT</version>
      <packaging>war</packaging>

      <name>project</name>
      <description>demo</description>

      <parent>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-parent</artifactId>
      <version>2.0.6.RELEASE</version>
      <relativePath /> <!-- lookup parent from repository -->
      </parent>

      <properties>
      <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
      <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
      <java.version>1.8</java.version>
      </properties>

      <dependencies>
      <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-data-elasticsearch</artifactId>
      </dependency>
      <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-data-mongodb</artifactId>
      </dependency>
      <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-data-rest</artifactId>
      </dependency>
      <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-groovy-templates</artifactId>
      </dependency>
      <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-mustache</artifactId>
      </dependency>
      <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-security</artifactId>
      </dependency>
      <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-thymeleaf</artifactId>
      </dependency>
      <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-web</artifactId>
      </dependency>
      <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-web-services</artifactId>
      </dependency>

      <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-devtools</artifactId>
      <scope>runtime</scope>
      </dependency>
      <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-tomcat</artifactId>
      <scope>provided</scope>
      </dependency>
      <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-test</artifactId>
      <scope>test</scope>
      </dependency>
      <dependency>
      <groupId>org.springframework.security</groupId>
      <artifactId>spring-security-test</artifactId>
      <scope>test</scope>
      </dependency>
      <dependency>
      <groupId>javax.xml.bind</groupId>
      <artifactId>jaxb-api</artifactId>
      <version>2.4.0-b180725.0427</version>
      </dependency>
      <!-- https://mvnrepository.com/artifact/org.mongodb.morphia/morphia -->
      <dependency>
      <groupId>org.mongodb.morphia</groupId>
      <artifactId>morphia</artifactId>
      <version>0.107</version>
      </dependency>
      <!-- https://mvnrepository.com/artifact/javax.persistence/javax.persistence-api -->
      <dependency>
      <groupId>javax.persistence</groupId>
      <artifactId>javax.persistence-api</artifactId>
      <version>2.2</version>
      </dependency>
      <!-- https://mvnrepository.com/artifact/com.querydsl/querydsl-apt -->
      <dependency>
      <groupId>com.querydsl</groupId>
      <artifactId>querydsl-mongodb</artifactId>
      <version>4.2.1</version>
      <exclusions>
      <exclusion>
      <groupId>org.mongodb</groupId>
      <artifactId>mongo-java-driver</artifactId>
      </exclusion>
      </exclusions>
      </dependency>
      </dependencies>

      <build>
      <plugins>
      <plugin>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-maven-plugin</artifactId>
      </plugin>
      <plugin>
      <groupId>com.mysema.maven</groupId>
      <artifactId>apt-maven-plugin</artifactId>
      <version>1.1.3</version>
      <dependencies>
      <dependency>
      <groupId>com.querydsl</groupId>
      <artifactId>querydsl-apt</artifactId>
      <version>4.2.1</version>
      </dependency>
      </dependencies>
      <executions>
      <execution>
      <phase>generate-sources</phase>
      <goals>
      <goal>process</goal>
      </goals>
      <configuration>
      <outputDirectory>target/generated-sources/annotations</outputDirectory>
      <processor>org.springframework.data.mongodb.repository.support.MongoAnnotationProcessor</processor>
      <logOnlyOnError>true</logOnlyOnError>
      </configuration>
      </execution>
      </executions>
      </plugin>
      </plugins>
      </build>


      </project>




      Test set: project.StoreBased.ApplicationTests



      Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 11.036 s <<< FAILURE! - in project.StoreBased.ApplicationTests
      contextLoads(project.StoreBased.ApplicationTests) Time elapsed: 0.002 s <<< ERROR!
      java.lang.IllegalStateException: Failed to load ApplicationContext
      Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'productBrandController' defined in file [C:UsersvinceDocumentsworkspace-spring-tool-suite-4-4.0.1.RELEASEproject(18.11.2018)targettest-classescomprojectprojectStoreBasedProductBrandController.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'productBrandRepository': Invocation of init method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.data.mongodb.repository.support.QuerydslMongoPredicateExecutor]: Constructor threw exception; nested exception is java.lang.IllegalArgumentException: Did not find a query class project.StoreBased.QProductBrand for domain class project.StoreBased.ProductBrand!
      Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'productBrandRepository': Invocation of init method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.data.mongodb.repository.support.QuerydslMongoPredicateExecutor]: Constructor threw exception; nested exception is java.lang.IllegalArgumentException: Did not find a query class project.StoreBased.QProductBrand for domain class project.project.StoreBased.ProductBrand!
      Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.data.mongodb.repository.support.QuerydslMongoPredicateExecutor]: Constructor threw exception; nested exception is java.lang.IllegalArgumentException: Did not find a query class project.StoreBased.QProductBrand for domain class project.StoreBased.ProductBrand!
      Caused by: java.lang.IllegalArgumentException: Did not find a query class project.StoreBased.QProductBrand for domain class project.StoreBased.ProductBrand!
      Caused by: java.lang.ClassNotFoundException: project.StoreBased.QProductBrand







      java spring maven spring-boot querydsl






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 19 '18 at 12:18







      vince

















      asked Nov 16 '18 at 21:51









      vincevince

      114




      114
























          0






          active

          oldest

          votes












          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53345913%2fconstructor-threw-exception-nested-exception-is-java-lang-illegalargumentexcept%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53345913%2fconstructor-threw-exception-nested-exception-is-java-lang-illegalargumentexcept%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Xamarin.iOS Cant Deploy on Iphone

          Glorious Revolution

          Dulmage-Mendelsohn matrix decomposition in Python