NiFi 定制处理器引入了标准工件的重复项

Jon*_*tia 1 apache-nifi

在 1.12 中引入之前,我已经编写了一个自定义处理器来处理多部分帖子。我的处理器和 nar 工作正常,但 nar 捆绑包引入了许多标准处理器的重复项,其版本号与我的自定义处理器的版本号相匹配。

在我引入 SSLContextService 控制器后,这种情况就开始发生。添加控制器服务需要添加

<dependency>
            <groupId>org.apache.nifi</groupId>
            <artifactId>nifi-standard-services-api-nar</artifactId>
            <version>1.11.4</version>
            <type>nar</type>
</dependency>
Run Code Online (Sandbox Code Playgroud)

根据apache nifi wiki上的指南,但完成的 nar 似乎包含标准 nifi 处理器的“2.1.1-SNAPSHOT”版本,例如 AttributesToJson 或 PutRecord 以及其他数十个处理器。

来自自定义处理器的重复工件

排除此依赖项会导致 nar 构建失败,因为缺少 SSLContexService 类。使用提供的范围构建一个大约相同大小的 nar,这会导致 NiFi 无法启动(到目前为止我还没有找到错误消息告诉我为什么,它只是在启动时死掉)。

有谁知道如何阻止创建这些重复项?整个 nar 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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>com.jontia</groupId>
        <artifactId>PostMultipartFormData</artifactId>
        <version>2.1.1-SNAPSHOT</version>
    </parent>

    <artifactId>nifi-multipart-nar</artifactId>
    <version>2.1.1-SNAPSHOT</version>
    <packaging>nar</packaging>
    <properties>
        <maven.javadoc.skip>true</maven.javadoc.skip>
        <source.skip>true</source.skip>
    </properties>

    <dependencies>
        <dependency>
            <groupId>com.jontia</groupId>
            <artifactId>nifi-multipart-processors</artifactId>
            <version>2.1.1-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>org.apache.nifi</groupId>
            <artifactId>nifi-standard-services-api-nar</artifactId>
            <version>1.11.4</version>
            <type>nar</type>
        </dependency>
    </dependencies>

</project>
Run Code Online (Sandbox Code Playgroud)

处理器 Pom;

<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>com.jontia</groupId>
        <artifactId>PostMultipartFormData</artifactId>
        <version>2.1.1-SNAPSHOT</version>
    </parent>

    <artifactId>nifi-multipart-processors</artifactId>
    <packaging>jar</packaging>

    <dependencies>
        <dependency>
            <groupId>org.apache.nifi</groupId>
            <artifactId>nifi-api</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.nifi</groupId>
            <artifactId>nifi-utils</artifactId>
            <version>1.11.4</version>
        </dependency>
        <dependency>
            <groupId>org.apache.nifi</groupId>
            <artifactId>nifi-ssl-context-service-api</artifactId>
            <version>1.11.4</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.nifi</groupId>
            <artifactId>nifi-proxy-configuration-api</artifactId>
            <version>1.11.4</version>
            <scope>provided</scope>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.apache.nifi/nifi-processor-utils -->
        <dependency>
            <groupId>org.apache.nifi</groupId>
            <artifactId>nifi-processor-utils</artifactId>
            <version>1.11.4</version>
        </dependency>
        <dependency>
            <groupId>org.apache.nifi</groupId>
            <artifactId>nifi-standard-processors</artifactId>
            <version>1.11.4</version>
        </dependency>

        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <version>4.5.9</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpcore</artifactId>
            <version>4.4.11</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpmime</artifactId>
            <version>4.5.12</version>
        </dependency>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-core</artifactId>
            <version>2.13.3</version>
        </dependency>
        <dependency>
            <groupId>org.apache.nifi</groupId>
            <artifactId>nifi-mock</artifactId>
            <version>1.11.4</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-simple</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>1.18.12</version>
        </dependency>
    </dependencies>
</project>
Run Code Online (Sandbox Code Playgroud)

Bry*_*nde 5

处理器 pom.xml 依赖于 nifi-standard-processors:

<dependency>
    <groupId>org.apache.nifi</groupId>
    <artifactId>nifi-standard-processors</artifactId>
    <version>1.11.4</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)

因此,当您构建 NAR 时,它会引入标准处理器的 JAR,因此现在它们都再次捆绑在您的 NAR 和标准 NAR 中。

您不应该依赖标准处理器。如果其中有一些您需要的代码,那么应该将其重构为某种类型的可重用通用模块,或者如果您尝试扩展处理器,您实际上应该将其复制到 NAR 中并进行所需的任何修改。