欢迎访问悦橙教程(wld5.com),关注java教程。悦橙教程  java问答|  每日更新
页面导航 : > > 文章正文

the import org.springframewok.test cannot be resolved,

来源: javaer 分享于  点击 18539 次 点评:137

the import org.springframewok.test cannot be resolved,


  在写Spring的单元测试时遇见了问题,注解@ContextConfiguration和SpringJUnit4ClassRunner.class无法导包。手动导包后错误为“the import org.springframewok.test cannot be resolved”。

 

首先检查是否在maven的POM.xml文件添加了相应的依赖,添加了。然后检查spring相关的jar包的版本是否一致,也是一致的。最后发现,是在导入spring test 和Junit的jar包时多了<scope>test</scope>。

 

删除这两句就可以了。

原因:scope为test表示依赖项目仅仅参与测试相关的工作,包括测试代码的编译,执行。在maven的目录结构下,测试类一般是放在src/test/java,而不是放在src/main/java下。我的测试类是在src/main/java下的,所以maven在编译的时候,因为<scope>test</scope>的限制而不引用jar包,因此将这两句删掉不要限制就好了。

相关文章

    暂无相关文章
相关栏目:

用户点评