【Apache NIFI 操作】Win10+ IDEA NiFi源码编译错误解决和本地运行
系统:Win10 x64
IDEA版本:IntelliJ IDEA 2019.2.3 (Ultimate Edition)
Maven版本:3.6.3
JDK版本:1.8
错误解决
报错1:

解决:大多是因为本地设置的JDK和项目使用的JDK版本不一致导致的,必须保持jdk版本一致,参考Win10+ IDEA NiFi源码编译配置一文。
报错2:
Could not transfer artifact xxx from/to xxx
[ERROR] Failed to execute goal on project nifi-jetty: Could not resolve dependencies for project org.apache.nifi:nifi-jetty:jar:1.8.0: Failed to collect dependencies at com.github.stefanbirkner:system-rules:jar:1.18.0 -> junit:junit-dep:jar:4.9.1-SNAPSHOT: Failed to read artifact descriptor for junit:junit-dep:jar:4.9.1-SNAPSHOT: Could not transfer artifact junit:junit-dep:pom:4.9.1-SNAPSHOT from/to jdk18 (http://www.myhost.com/maven/jdk18): Transfer failed for http://www.myhost.com/maven/jdk18/junit/junit-dep/4.9.1-SNAPSHOT/junit-dep-4.9.1-SNAPSHOT.pom 500 Internal Server Error -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal on project nifi-jetty: Could not resolve dependencies for project org.apache.nifi:nifi-jetty:jar:1.8.0: Failed to collect dependencies at com.github.stefanbirkner:system-rules:jar:1.18.0 -> junit:junit-dep:jar:4.9.1-SNAPSHOT
at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.getDependencies (LifecycleDependencyResolver.java:269)
at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.resolveProjectDependencies (LifecycleDependencyResolver.java:147)
方法一:
这个问题主要就是在你下载相关的依赖包时,没有下载成功照成的,需要找到对应的maven库包,删除以 .lastUpdated 结尾的文件,然后重新下载,一般可以得到解决。
方法二:
按照方法一删除maven本地仓库中的以 lastUpdated 结尾的文件,然后将maven的配置文件中的仓库镜像改为阿里云或者其他国内进行地址,重新import一下。
比如下面的镜像,在setting.xml中的mirrors中添加阿里云镜像:
<mirror>
<id>alimaven</id>
<mirrorOf>central</mirrorOf>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/repositories/central/</url>
</mirror>
编译成功并本地运行
编译大约需要1.5小时:
编译结束,在该目录下双击run-nifi.bat:
会弹出CMD,正在启动NiFi:
在浏览器输入
http://localhost:8080/nifi/
若出现以下界面,则说明编译成功,并本地启动了NiFi: