今天使用maven打包項目的時候出現下面的錯誤,提示org.junit不存在。
錯誤信息內容如下:
[ERROR] /Users/aven/Documents/workspace/share/src/test/java/com/weixiao/share/test/TestMyBatis.java:[8,16] 錯誤: 程序包org.junit不存在 [ERROR] /Users/aven/Documents/workspace/share/src/test/java/com/weixiao/share/test/TestMyBatis.java:[9,23] 錯誤: 程序包org.junit.runner不存在 [ERROR] /Users/aven/Documents/workspace/share/src/test/java/com/weixiao/share/test/TestMyBatis.java:[18,1] 錯誤: 找不到符號 [ERROR] 類 RunWith /Users/aven/Documents/workspace/share/src/test/java/com/weixiao/share/test/TestMyBatis.java:[37,2] 錯誤: 找不到符號 [INFO] 4 errors [INFO] ------------------------------------------------------------- [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 15.024 s [INFO] Finished at: 2017-04-14T13:34:37+08:00 [INFO] Final Memory: 31M/280M [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:testCompile (default-testCompile) on project share: Compilation failure: Compilation failure: [ERROR] /Users/aven/Documents/workspace/share/src/test/java/com/weixiao/share/test/TestMyBatis.java:[8,16] 錯誤: 程序包org.junit不存在 [ERROR] /Users/aven/Documents/workspace/share/src/test/java/com/weixiao/share/test/TestMyBatis.java:[9,23] 錯誤: 程序包org.junit.runner不存在 [ERROR] /Users/aven/Documents/workspace/share/src/test/java/com/weixiao/share/test/TestMyBatis.java:[18,1] 錯誤: 找不到符號 [ERROR] 類 RunWith [ERROR] /Users/aven/Documents/workspace/share/src/test/java/com/weixiao/share/test/TestMyBatis.java:[37,2] 錯誤: 找不到符號 [ERROR] -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
但是程序測試的時候是沒有問題的,這也就說明junit的依賴是引入了的。
修改方法:修改下面的代碼
最開始的如下:
修改后的代碼:
然后發現進入可以達成了jar包,具體為什么還不清楚。