问题:我的maven中引入了junit
<dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.9</version> <scope>test</scope> </dependency>
[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
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。
因为你的junit的jar包的scope是test的,但是你的单元测时的代码放到了/src/main/java/里面,这是不对的,应该放到/src/test/java/里面,这些都是有讲究的,你看你的报错信息,里面已经非常明显了噢,这样啊原来,太感谢你了!用于单元测试的类你是不是放到了main里面,应该放到test里面哦
回复<aclass='referer'target='_blank'>@lavare_z:“[ERROR]/E:/workspace/study/shiroexampleMavenWebapp/src/main/java/“我说的是这个main没有,就是放在类中的,现在重新建了一个工程,没有那个问题了。但是说不定以后还会出现
写了<spanstyle="font-family:Consolas,"font-size:14px;line-height:15.4px;background-color:#FFFFFF;">程序包org.junit不存在,肯定是不存在,不会骗你的,好好到底有没有正确引入了
<spanstyle="background-color:#FFFFFF;">也可以用-DskipTests,忽略测试
好的谢谢啦,我试试。现在重新建了一个工程,没有那个问题了。但是说不定以后还会出现