简体   繁体   English

NiFi 开发自定义处理器:导入 org.apache.nifi.processors 错误

[英]NiFi developing custom processor: import org.apache.nifi.processors error

I am trying to implement a custom processors in NiFi with mvn archetype:generate and I would like to import a class from org.apache.nifi.processors (in particular standard.util.* ), but it gives me error ( cannot be resolved ).我正在尝试使用mvn archetype:generate在 NiFi 中实现自定义处理器,我想从org.apache.nifi.processors (特别是standard.util.* )导入一个类,但它给了我错误( cannot be resolved )。

My current workaround is to copy the classes that I want in my package, but what should I do to make it visible directly from the nifi package?我目前的解决方法是在我的包中复制我想要的类,但是我应该怎么做才能直接从 nifi 包中看到它? Should I modify the pom.xml ?我应该修改 pom.xml 吗? Thanks in advance提前致谢

The content of the pom.xml is the one generated by the mvn archetype:generate command: pom.xml 的内容是mvn archetype:generate命令mvn archetype:generate

<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.example.nifi</groupId>
        <artifactId>stream-processorr</artifactId>
        <version>1.0-SNAPSHOT</version>
    </parent>

    <artifactId>nifi-StreamProcessor-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.10.0</version>
        </dependency>
        <dependency>
            <groupId>org.apache.nifi</groupId>
            <artifactId>nifi-mock</artifactId>
            <version>1.10.0</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>
    </dependencies>
</project>

Presumably, and from a pure Maven standpoint, you would likely need to depend on nifi-standard-processors to get that package to resolve.据推测,从纯 Maven 的角度来看,您可能需要依赖 nifi-standard-processors 来解决该包。 That is where the majority of classes in that package exist.这就是该包中大多数类存在的地方。 Of course, this depends on the specific class(es) of interest.当然,这取决于感兴趣的特定类。

As a bit of context from the NiFi project perspective, the package listed is mostly tailored toward helper classes for the processors in the standard bundle.从 NiFi 项目的角度来看,列出的包主要是针对标准包中处理器的帮助程序类量身定制的。 It is typically not a good practice to depend on these in other NAR bundles.在其他 NAR 包中依赖这些通常不是一个好习惯。 However, if you share use case it may make sense to extract these to a separate module for wider use.但是,如果您共享用例,将它们提取到单独的模块以供更广泛使用可能是有意义的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM