编译到 Test utils : Junit 模块,就报错了
maven 版本: 3.2.5 jdk 版本:1.8.0_251 flink 版本: flink 1.12.2 执行的命令:mvn clean install -DskipTests -Dfast 错误信息: [ERROR] COMPILATION ERROR : [INFO] ------------------------------------------------------------- [ERROR] /data/flink-release-1.12.2/flink-test-utils-parent/flink-test-utils-junit/src/main/java/org/apache/flink/core/testutils/CommonTestUtils.java:[38,27] package org.hamcrest does not exist [ERROR] /data/flink-release-1.12.2/flink-test-utils-parent/flink-test-utils-junit/src/main/java/org/apache/flink/core/testutils/CommonTestUtils.java:[38,1] static import only from classes and interfaces [ERROR] /data/flink-release-1.12.2/flink-test-utils-parent/flink-test-utils-junit/src/main/java/org/apache/flink/core/testutils/CommonTestUtils.java:[39,27] package org.hamcrest does not exist [INFO] Reactor Summary: [INFO] [INFO] Flink : Tools : Force Shading ...................... SUCCESS [ 1.042 s] [INFO] Flink : ............................................ SUCCESS [ 1.404 s] [INFO] Flink : Annotations ................................ SUCCESS [ 0.735 s] [INFO] Flink : Test utils : ............................... SUCCESS [ 0.042 s] [INFO] Flink : Test utils : Junit ......................... FAILURE [ 0.283 s] 而且我看 flink-test-utils-parent/pom.xml 和 flink-test-utils-junit/pom.xml 的确没加 org.hamcrest 相关依赖啊。 请问大家下,原因是什么呢? Zhiwen Sun |
才编译到 Test utils : Junit 模块,就报错了
maven 版本: 3.2.5 jdk 版本:1.8.0_251 flink 版本: flink 1.12.2 执行的命令:mvn clean install -DskipTests -Dfast 错误信息: [ERROR] COMPILATION ERROR : [INFO] ------------------------------------------------------------- [ERROR] /data/flink-release-1.12.2/flink-test-utils-parent/flink-test-utils-junit/src/main/java/org/apache/flink/core/testutils/CommonTestUtils.java:[38,27] package org.hamcrest does not exist [ERROR] /data/flink-release-1.12.2/flink-test-utils-parent/flink-test-utils-junit/src/main/java/org/apache/flink/core/testutils/CommonTestUtils.java:[38,1] static import only from classes and interfaces [ERROR] /data/flink-release-1.12.2/flink-test-utils-parent/flink-test-utils-junit/src/main/java/org/apache/flink/core/testutils/CommonTestUtils.java:[39,27] package org.hamcrest does not exist [INFO] Reactor Summary: [INFO] [INFO] Flink : Tools : Force Shading ...................... SUCCESS [ 1.042 s] [INFO] Flink : ............................................ SUCCESS [ 1.404 s] [INFO] Flink : Annotations ................................ SUCCESS [ 0.735 s] [INFO] Flink : Test utils : ............................... SUCCESS [ 0.042 s] [INFO] Flink : Test utils : Junit ......................... FAILURE [ 0.283 s] 看起来是缺少 org.hamcrest 相关依赖 我看 flink-test-utils-parent/pom.xml 和 flink-test-utils-junit/pom.xml 的确没加 org.hamcrest 相关依赖, 不知道这个是怎么工作的。 请问大家下,原因是什么呢? Zhiwen Sun |
在我手动加上依赖后,这个模块,能编译通过了,但 runtime 又失败了。
INFO] --- scala-maven-plugin:3.2.2:compile (scala-compile-first) @ flink-runtime_2.11 --- [INFO] /data/flink-release-1.12.2/flink-runtime/src/main/java:-1: info: compiling [INFO] /data/flink-release-1.12.2/flink-runtime/src/main/scala:-1: info: compiling [INFO] Compiling 1958 source files to /data/flink-release-1.12.2/flink-runtime/target/classes at 1622169188312 [ERROR] java.lang.NoClassDefFoundError: scala/reflect/internal/Trees [INFO] at java.lang.ClassLoader.defineClass1(Native Method) [INFO] at java.lang.ClassLoader.defineClass(ClassLoader.java:756) [INFO] at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) [INFO] at java.net.URLClassLoader.defineClass(URLClassLoader.java:468) [INFO] at java.net.URLClassLoader.access$100(URLClassLoader.java:74) [INFO] at java.net.URLClassLoader$1.run(URLClassLoader.java:369) [INFO] at java.net.URLClassLoader$1.run(URLClassLoader.java:363) [INFO] at java.security.AccessController.doPrivileged(Native Method) [INFO] at java.net.URLClassLoader.findClass(URLClassLoader.java:362) [INFO] at java.lang.ClassLoader.loadClass(ClassLoader.java:418) [INFO] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355) [INFO] at java.lang.ClassLoader.loadClass(ClassLoader.java:351) [INFO] at java.lang.ClassLoader.defineClass1(Native Method) [INFO] at java.lang.ClassLoader.defineClass(ClassLoader.java:756) [INFO] at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) [INFO] at java.net.URLClassLoader.defineClass(URLClassLoader.java:468) [INFO] at java.net.URLClassLoader.access$100(URLClassLoader.java:74) [INFO] at java.net.URLClassLoader$1.run(URLClassLoader.java:369) [INFO] at java.net.URLClassLoader$1.run(URLClassLoader.java:363) [INFO] at java.security.AccessController.doPrivileged(Native Method) [INFO] at java.net.URLClassLoader.findClass(URLClassLoader.java:362) [INFO] at java.lang.ClassLoader.loadClass(ClassLoader.java:418) [INFO] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355) [INFO] at java.lang.ClassLoader.loadClass(ClassLoader.java:351) [INFO] at java.lang.Class.getDeclaredMethods0(Native Method) [INFO] at java.lang.Class.privateGetDeclaredMethods(Class.java:2701) [INFO] at java.lang.Class.privateGetMethodRecursive(Class.java:3048) [INFO] at java.lang.Class.getMethod0(Class.java:3018) [INFO] at java.lang.Class.getMethod(Class.java:1784) [INFO] at scala_maven_executions.MainHelper.runMain(MainHelper.java:155) [INFO] at scala_maven_executions.MainWithArgsInFile.main(MainWithArgsInFile.java:26) [INFO] Caused by: java.lang.ClassNotFoundException: scala.reflect.internal.Trees [INFO] at java.net.URLClassLoader.findClass(URLClassLoader.java:382) [INFO] at java.lang.ClassLoader.loadClass(ClassLoader.java:418) [INFO] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355) [INFO] at java.lang.ClassLoader.loadClass(ClassLoader.java:351) [INFO] ... 31 more [INFO] ------------------------------------------------------------------------ [INFO] Reactor Summary: [INFO] [INFO] Flink : Tools : Force Shading ...................... SUCCESS [ 1.093 s] [INFO] Flink : ............................................ SUCCESS [ 1.168 s] [INFO] Flink : Annotations ................................ SUCCESS [ 1.218 s] [INFO] Flink : Test utils : ............................... SUCCESS [ 0.047 s] [INFO] Flink : Test utils : Junit ......................... SUCCESS [ 0.795 s] [INFO] Flink : Metrics : .................................. SUCCESS [ 0.037 s] [INFO] Flink : Metrics : Core ............................. SUCCESS [ 0.501 s] [INFO] Flink : Core ....................................... SUCCESS [ 17.510 s] [INFO] Flink : Java ....................................... SUCCESS [ 2.467 s] [INFO] Flink : Queryable state : .......................... SUCCESS [ 0.029 s] [INFO] Flink : Queryable state : Client Java .............. SUCCESS [ 3.106 s] [INFO] Flink : FileSystems : .............................. SUCCESS [ 0.031 s] [INFO] Flink : FileSystems : Hadoop FS .................... SUCCESS [ 3.457 s] [INFO] Flink : Runtime .................................... FAILURE [ 18.086 s] 然后我修改 scala 的版本为 2.12 相关命令: mvn clean install -DskipTests -Dfast -Dscala-2.12 目前能够正常编译了,我看 release 版本支持 scala-2.11 的。是我的环境有问题吗? Zhiwen Sun On Fri, May 28, 2021 at 10:28 AM Zhiwen Sun <[hidden email]> wrote: > 才编译到 Test utils : Junit 模块,就报错了 > > maven 版本: 3.2.5 > jdk 版本:1.8.0_251 > flink 版本: flink 1.12.2 > 执行的命令:mvn clean install -DskipTests -Dfast > > 错误信息: > > [ERROR] COMPILATION ERROR : > [INFO] ------------------------------------------------------------- > [ERROR] > /data/flink-release-1.12.2/flink-test-utils-parent/flink-test-utils-junit/src/main/java/org/apache/flink/core/testutils/CommonTestUtils.java:[38,27] > package org.hamcrest does not exist > [ERROR] > /data/flink-release-1.12.2/flink-test-utils-parent/flink-test-utils-junit/src/main/java/org/apache/flink/core/testutils/CommonTestUtils.java:[38,1] > static import only from classes and interfaces > [ERROR] > /data/flink-release-1.12.2/flink-test-utils-parent/flink-test-utils-junit/src/main/java/org/apache/flink/core/testutils/CommonTestUtils.java:[39,27] > package org.hamcrest does not exist > > [INFO] Reactor Summary: > [INFO] > [INFO] Flink : Tools : Force Shading ...................... SUCCESS [ > 1.042 s] > [INFO] Flink : ............................................ SUCCESS [ > 1.404 s] > [INFO] Flink : Annotations ................................ SUCCESS [ > 0.735 s] > [INFO] Flink : Test utils : ............................... SUCCESS [ > 0.042 s] > [INFO] Flink : Test utils : Junit ......................... FAILURE [ > 0.283 s] > > > 看起来是缺少 org.hamcrest 相关依赖 > 我看 flink-test-utils-parent/pom.xml 和 flink-test-utils-junit/pom.xml > 的确没加 org.hamcrest 相关依赖, 不知道这个是怎么工作的。 > > 请问大家下,原因是什么呢? > > > Zhiwen Sun > > |
In reply to this post by pensz
Hi, org.hamcrest 是 junit 的依赖
On Fri, May 28, 2021 at 10:28 AM Zhiwen Sun <[hidden email]> wrote: > 才编译到 Test utils : Junit 模块,就报错了 > > maven 版本: 3.2.5 > jdk 版本:1.8.0_251 > flink 版本: flink 1.12.2 > 执行的命令:mvn clean install -DskipTests -Dfast > > 错误信息: > > [ERROR] COMPILATION ERROR : > [INFO] ------------------------------------------------------------- > [ERROR] > > /data/flink-release-1.12.2/flink-test-utils-parent/flink-test-utils-junit/src/main/java/org/apache/flink/core/testutils/CommonTestUtils.java:[38,27] > package org.hamcrest does not exist > [ERROR] > > /data/flink-release-1.12.2/flink-test-utils-parent/flink-test-utils-junit/src/main/java/org/apache/flink/core/testutils/CommonTestUtils.java:[38,1] > static import only from classes and interfaces > [ERROR] > > /data/flink-release-1.12.2/flink-test-utils-parent/flink-test-utils-junit/src/main/java/org/apache/flink/core/testutils/CommonTestUtils.java:[39,27] > package org.hamcrest does not exist > > [INFO] Reactor Summary: > [INFO] > [INFO] Flink : Tools : Force Shading ...................... SUCCESS [ > 1.042 s] > [INFO] Flink : ............................................ SUCCESS [ > 1.404 s] > [INFO] Flink : Annotations ................................ SUCCESS [ > 0.735 s] > [INFO] Flink : Test utils : ............................... SUCCESS [ > 0.042 s] > [INFO] Flink : Test utils : Junit ......................... FAILURE [ > 0.283 s] > > > 看起来是缺少 org.hamcrest 相关依赖 > 我看 flink-test-utils-parent/pom.xml 和 flink-test-utils-junit/pom.xml > 的确没加 org.hamcrest 相关依赖, 不知道这个是怎么工作的。 > > 请问大家下,原因是什么呢? > > > Zhiwen Sun > |
谢谢,看了下,junit 的确依赖 org.hamcrest ,而且相关版本都没问题。
那这个报错的原因是什么呢? 什么地方导致 hamcrest 被 exclude 了?然后手动增加了dependency 就好了? 代码拉下来没修改过。 Zhiwen Sun On Fri, May 28, 2021 at 10:58 AM Shuo Cheng <[hidden email]> wrote: > Hi, org.hamcrest 是 junit 的依赖 > > On Fri, May 28, 2021 at 10:28 AM Zhiwen Sun <[hidden email]> wrote: > > > 才编译到 Test utils : Junit 模块,就报错了 > > > > maven 版本: 3.2.5 > > jdk 版本:1.8.0_251 > > flink 版本: flink 1.12.2 > > 执行的命令:mvn clean install -DskipTests -Dfast > > > > 错误信息: > > > > [ERROR] COMPILATION ERROR : > > [INFO] ------------------------------------------------------------- > > [ERROR] > > > > > /data/flink-release-1.12.2/flink-test-utils-parent/flink-test-utils-junit/src/main/java/org/apache/flink/core/testutils/CommonTestUtils.java:[38,27] > > package org.hamcrest does not exist > > [ERROR] > > > > > /data/flink-release-1.12.2/flink-test-utils-parent/flink-test-utils-junit/src/main/java/org/apache/flink/core/testutils/CommonTestUtils.java:[38,1] > > static import only from classes and interfaces > > [ERROR] > > > > > /data/flink-release-1.12.2/flink-test-utils-parent/flink-test-utils-junit/src/main/java/org/apache/flink/core/testutils/CommonTestUtils.java:[39,27] > > package org.hamcrest does not exist > > > > [INFO] Reactor Summary: > > [INFO] > > [INFO] Flink : Tools : Force Shading ...................... SUCCESS [ > > 1.042 s] > > [INFO] Flink : ............................................ SUCCESS [ > > 1.404 s] > > [INFO] Flink : Annotations ................................ SUCCESS [ > > 0.735 s] > > [INFO] Flink : Test utils : ............................... SUCCESS [ > > 0.042 s] > > [INFO] Flink : Test utils : Junit ......................... FAILURE [ > > 0.283 s] > > > > > > 看起来是缺少 org.hamcrest 相关依赖 > > 我看 flink-test-utils-parent/pom.xml 和 flink-test-utils-junit/pom.xml > > 的确没加 org.hamcrest 相关依赖, 不知道这个是怎么工作的。 > > > > 请问大家下,原因是什么呢? > > > > > > Zhiwen Sun > > > |
看了下依赖树,似乎是因为 org.powermock 引入了 hamcrest-core 导致 junit 无法引入,但 junit
在前面,按道理应该它应该将 hamcrest-core 引入到 compile scope 。 [INFO] ------------------------------------------------------------------------ [INFO] Building Flink : Test utils : Junit 1.12.2 [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- maven-dependency-plugin:3.1.1:tree (default-cli) @ flink-test-utils-junit --- [INFO] org.apache.flink:flink-test-utils-junit:jar:1.12.2 [INFO] +- junit:junit:jar:4.12:compile [INFO] +- org.apache.logging.log4j:log4j-slf4j-impl:jar:2.12.1:compile [INFO] +- org.apache.logging.log4j:log4j-api:jar:2.12.1:compile [INFO] +- org.apache.logging.log4j:log4j-core:jar:2.12.1:compile [INFO] +- org.apache.flink:force-shading:jar:1.12.2:compile [INFO] +- org.slf4j:slf4j-api:jar:1.7.15:compile [INFO] +- com.google.code.findbugs:jsr305:jar:1.3.9:compile [INFO] +- org.mockito:mockito-core:jar:2.21.0:test [INFO] | +- net.bytebuddy:byte-buddy:jar:1.8.15:test [INFO] | +- net.bytebuddy:byte-buddy-agent:jar:1.8.15:test [INFO] | \- org.objenesis:objenesis:jar:2.1:test [INFO] +- org.powermock:powermock-module-junit4:jar:2.0.4:test [INFO] | +- org.powermock:powermock-module-junit4-common:jar:2.0.4:test [INFO] | | +- org.powermock:powermock-reflect:jar:2.0.4:test [INFO] | | \- org.powermock:powermock-core:jar:2.0.4:test [INFO] | | \- org.javassist:javassist:jar:3.24.0-GA:test [INFO] | \- org.hamcrest:hamcrest-core:jar:1.3:test [INFO] +- org.powermock:powermock-api-mockito2:jar:2.0.4:test [INFO] | \- org.powermock:powermock-api-support:jar:2.0.4:test [INFO] +- org.hamcrest:hamcrest-all:jar:1.3:test [INFO] \- org.apache.logging.log4j:log4j-1.2-api:jar:2.12.1:test [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ Zhiwen Sun On Fri, May 28, 2021 at 11:12 AM Zhiwen Sun <[hidden email]> wrote: > 谢谢,看了下,junit 的确依赖 org.hamcrest ,而且相关版本都没问题。 > > 那这个报错的原因是什么呢? 什么地方导致 hamcrest 被 exclude 了?然后手动增加了dependency 就好了? 代码拉下来没修改过。 > > Zhiwen Sun > > > > On Fri, May 28, 2021 at 10:58 AM Shuo Cheng <[hidden email]> wrote: > >> Hi, org.hamcrest 是 junit 的依赖 >> >> On Fri, May 28, 2021 at 10:28 AM Zhiwen Sun <[hidden email]> wrote: >> >> > 才编译到 Test utils : Junit 模块,就报错了 >> > >> > maven 版本: 3.2.5 >> > jdk 版本:1.8.0_251 >> > flink 版本: flink 1.12.2 >> > 执行的命令:mvn clean install -DskipTests -Dfast >> > >> > 错误信息: >> > >> > [ERROR] COMPILATION ERROR : >> > [INFO] ------------------------------------------------------------- >> > [ERROR] >> > >> > >> /data/flink-release-1.12.2/flink-test-utils-parent/flink-test-utils-junit/src/main/java/org/apache/flink/core/testutils/CommonTestUtils.java:[38,27] >> > package org.hamcrest does not exist >> > [ERROR] >> > >> > >> /data/flink-release-1.12.2/flink-test-utils-parent/flink-test-utils-junit/src/main/java/org/apache/flink/core/testutils/CommonTestUtils.java:[38,1] >> > static import only from classes and interfaces >> > [ERROR] >> > >> > >> /data/flink-release-1.12.2/flink-test-utils-parent/flink-test-utils-junit/src/main/java/org/apache/flink/core/testutils/CommonTestUtils.java:[39,27] >> > package org.hamcrest does not exist >> > >> > [INFO] Reactor Summary: >> > [INFO] >> > [INFO] Flink : Tools : Force Shading ...................... SUCCESS [ >> > 1.042 s] >> > [INFO] Flink : ............................................ SUCCESS [ >> > 1.404 s] >> > [INFO] Flink : Annotations ................................ SUCCESS [ >> > 0.735 s] >> > [INFO] Flink : Test utils : ............................... SUCCESS [ >> > 0.042 s] >> > [INFO] Flink : Test utils : Junit ......................... FAILURE [ >> > 0.283 s] >> > >> > >> > 看起来是缺少 org.hamcrest 相关依赖 >> > 我看 flink-test-utils-parent/pom.xml 和 flink-test-utils-junit/pom.xml >> > 的确没加 org.hamcrest 相关依赖, 不知道这个是怎么工作的。 >> > >> > 请问大家下,原因是什么呢? >> > >> > >> > Zhiwen Sun >> > >> > |
Free forum by Nabble | Edit this page |