java - 尝试使用 MongoDB 设置 Querydsl 3.6.0,但未找到 MorphiaAnnotationProcessor

标签 java mongodb maven querydsl

我有一个用于 mongodb 的小示例项目,但无法让注释处理器工作。我使用的示例来自:

http://www.querydsl.com/static/querydsl/latest/reference/html/ch02s07.html

运行 mvn clean install 产生:

Annotation processor 'com.querydsl.mongodb.morphia.MorphiaAnnotationProcessor' not found

我到处寻找那个处理器。就是找不到。这是 pom.xml:

<?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.stevesando</groupId>
<artifactId>FindAll</artifactId>
<version>1.0-SNAPSHOT</version>

<dependencies>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-mongodb</artifactId>
        <version>1.2.1.RELEASE</version>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <version>1.2.1.RELEASE</version>
    </dependency>

    <dependency>
        <groupId>com.mysema.querydsl</groupId>
        <artifactId>querydsl-mongodb</artifactId>
        <version>3.6.0</version>
    </dependency>

    <dependency>
        <groupId>com.mysema.querydsl</groupId>
        <artifactId>querydsl-apt</artifactId>
        <version>3.6.0</version>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-log4j12</artifactId>
        <version>1.6.1</version>
    </dependency>

</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <source>1.7</source>
                <target>1.7</target>
                <encoding>UTF-8</encoding>
            </configuration>
        </plugin>

        <plugin>
            <groupId>com.mysema.maven</groupId>
            <artifactId>apt-maven-plugin</artifactId>
            <version>1.1.3</version>
            <executions>
                <execution>
                    <goals>
                        <goal>process</goal>
                    </goals>
                    <configuration>
                        <outputDirectory>target/generated-sources/java</outputDirectory>
                        <processor>com.querydsl.mongodb.morphia.MorphiaAnnotationProcessor</processor>
                    </configuration>
                </execution>
            </executions>
        </plugin>

    </plugins>
</build>

最佳答案

使用 Spring Data,你应该使用 org.springframework.data.mongodb.repository.support.MongoAnnotationProcessor

Spring Data Mongo provides a custom APT processor to generate the Metamodels instead of the one provided in QueryDSL, it will scan the Spring specific @Document instead of the Morphia specific annotations.

关于java - 尝试使用 MongoDB 设置 Querydsl 3.6.0,但未找到 MorphiaAnnotationProcessor,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28158217/

相关文章:

java - 邻接矩阵 : premature ending of search, 上的广度优先算法返回大小为 1 的队列?

java - 网络服务 : Request-Response Mapper

Mongodb 计数数组组合

mongodb - 防止 mongodb 接受非本地连接

java - Mule 3.5.0 与 Maven 失败

java - 从 JSON 数组字符串创建 POJO 对象

java - Android - 空对象引用错误

javascript - 是否可以在 Mongodb 上模拟大数据流?

java - 如何将 Maven zip 依赖项放在类路径上以进行 Java 测试

java - 创建名称为 'clientsDaoImpl' : Injection of autowired dependencies failed; 的 bean 时出错