有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java Eclipse查看库,但无法导入它

我有一个奇怪的情况:

我在课堂上写:

...
    import org.springframework.test.context.web.WebAppConfiguration;
    //import org.springframework.test.web.servlet.MockMvc;

    @WebAppConfiguration
    @ContextConfiguration(locations = { "classpath:/test/BeanConfig.xml" })
    public class CandidateControllerTest {
...

如果我键入ctrl+鼠标左键并在WebAppConfiguration上移动光标,我会看到:

enter image description here

但在我的编辑中,我看到:

enter image description here

如果我将光标移动到某个位置,我会看到一条消息:

WebAppConfiguration cannot be resolved to a type

我如何解决这个问题

解决

我的应用程序有两个模块。在核心模块中写入了对弹簧测试(测试范围)的依赖性。当我在第二个模块中编写依赖项时,它已经开始工作了


共 (1) 个答案

  1. # 1 楼答案

    向项目类路径添加适当的依赖项,或者如果使用maven,可能会解决错误的spring版本