您好,欢迎来到[编程问答]网站首页   源码下载   电子书籍   软件下载   专题
当前位置:首页 >> 编程问答 >> Java >> 在maven中使用junit执行install时报错

在maven中使用junit执行install时报错

来源:网络整理     时间:2016/7/21 0:11:23     关键词:

关于网友提出的“ 在maven中使用junit执行install时报错”问题疑问,本网通过在网上对“ 在maven中使用junit执行install时报错”有关的相关答案进行了整理,供用户进行参考,详细问题解答如下:

问题: 在maven中使用junit执行install时报错
描述:

问题:我的maven中引入了junit


			junit
			junit
			4.9
			test
		
然后当我对pom.xml文件执行install的时候就报错了,弄了好几天都没办法,求大神指点一下小弟啊。
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project shiroexample: Compilation failure: Compilation failure:
[ERROR] /E:/workspace/study/shiroexample Maven Webapp/src/main/java/com/shiro/chapter2/LoginLogoutTest.java:[3,17] 程序包org.junit不存在
[ERROR] /E:/workspace/study/shiroexample Maven Webapp/src/main/java/com/shiro/chapter2/LoginLogoutTest.java:[6,10] 找不到符号
[ERROR] 符号:   类 Test
[ERROR] 位置: 类 com.shiro.chapter2.LoginLogoutTest
[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

解决方案1:

因为你的junit的jar包的scope是test的,但是你的单元测时的代码放到了/src/main/java/里面,这是不对的,应该放到/src/test/java/里面,这些都是有讲究的,你看你的报错信息,里面已经非常明显了

解决方案2:

写了程序包org.junit不存在,肯定是不存在,不会骗你的,好好到底有没有正确引入了

也可以用-DskipTests,忽略测试

解决方案3:

用于单元测试的类你是不是放到了main里面,应该放到test里面哦


以上介绍了“ 在maven中使用junit执行install时报错”的问题解答,希望对有需要的网友有所帮助。
本文网址链接:http://www.codes51.com/itwd/2837154.html

相关图片

相关文章