【问题标题】:Simple annotation processor library project with Maven使用 Maven 的简单注释处理器库项目
【发布时间】:2021-06-03 01:14:20
【问题描述】:

我正在尝试创建一个简单的库,该库使用 Netbeans 12.3 使用 Maven 定义注释和注释处理器。该库将由使用注释的 Web 项目使用。

问题是编译库时没有找到处理器类,虽然在源码中:“Annotation processor 'bandung.processor.CommandProcessor' not found”

(注释在以前版本的 Netbeans 下的非 Maven 项目中运行良好。)

这是 POM:

<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.ipserlab</groupId>
    <artifactId>Bandung</artifactId>
    <version>1.0</version>
    <packaging>jar</packaging>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>11</maven.compiler.source>
        <maven.compiler.target>11</maven.compiler.target>
    </properties>
    <dependencies>
        <dependency>
            <groupId>commons-codec</groupId>
            <artifactId>commons-codec</artifactId>
            <version>1.15</version>
        </dependency>
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <version>4.5.3</version>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-email</artifactId>
            <version>1.5</version>
        </dependency>
        <dependency>
            <groupId>org.apache.lucene</groupId>
            <artifactId>lucene-analyzers-common</artifactId>
            <version>5.4.1</version>
        </dependency>
        <dependency>
            <groupId>org.htmlparser</groupId>
            <artifactId>HTMLParserProject</artifactId>
            <version>2.1</version>
            <type>pom</type>
        </dependency>
        <dependency>
            <groupId>org.htmlparser</groupId>
            <artifactId>htmlparser</artifactId>
            <version>2.1</version>
        </dependency>
        <dependency>
            <groupId>commons-fileupload</groupId>
            <artifactId>commons-fileupload</artifactId>
            <version>1.4</version>
        </dependency>
        <dependency>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
        </dependency>
        <dependency>
            <groupId>com.google.auto.service</groupId>
            <artifactId>auto-service</artifactId>
            <version>1.0</version>
        </dependency>
        <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-web-api</artifactId>
            <version>7.0</version>
        </dependency>
    </dependencies>
    
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.5.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                    <encoding>UTF-8</encoding>
                    <generatedSourcesDirectory>${project.build.directory}/generated-sources/</generatedSourcesDirectory>
                    <annotationProcessors>
                        <annotationProcessor>
                            bandung.processor.CommandProcessor
                        </annotationProcessor>
                        <annotationProcessor>
                            bandung.processor.ModelProcessor
                        </annotationProcessor>
                    </annotationProcessors>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

【问题讨论】:

    标签: java maven annotations annotation-processing


    【解决方案1】:

    我只需要添加

    <proc>none</proc>
    

    到配置。感谢 Malav Doshi。

    【讨论】:

    • 也请接受这个答案,因为它显然解决了您的问题。接受的答案对社区更有帮助。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-09-29
    • 2012-12-28
    • 1970-01-01
    相关资源
    最近更新 更多