简体   繁体   English

Eclipse看到库但无法导入它

[英]Eclipse see library but cannot import it

I have strange situation: 我有奇怪的情况:

I write class: 我写课:

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

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

If I type ctrl+mouse left button and move cursor on WebAppConfiguration I see: 如果我键入ctrl +鼠标左键并在WebAppConfiguration上移动光标,我看到:

在此输入图像描述

But in my redactor I see: 但在我的编辑器中,我看到:

在此输入图像描述

if I move cursor for anotation I saw message: 如果我移动光标进行anotation我看到了消息:

WebAppConfiguration cannot be resolved to a type WebAppConfiguration无法解析为某种类型

How ti fix it this problem? 怎么解决这个问题呢?

RESOLVE 解决

my application has 2 modules. 我的应用程序有2个模块。 dependendency for spring test(test scope) was writing in core module. 弹簧测试的依赖性(测试范围)是在核心模块中编写的。 when I wrote dependency in second module - it had become to work. 当我在第二个模块中编写依赖项时 - 它已经成为可行的。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM