IDEA代码运行无误,但是编译器爆红问题

0 阅读1分钟
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-context</artifactId>
    <version>5.3.21</version>
</dependency>

Main.java

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class Main {
    public static void main(String[] args) {
        ApplicationContext classPathXmlApplicationContext = new ClassPathXmlApplicationContext("spring.xml");
        MyBean myBean = (MyBean) classPathXmlApplicationContext.getBean("myBean");
        System.out.println(myBean);
    }
}

org.springframework.context这里的context一直爆红,并且ApplicationContext等类也爆红,但是运行main方法没有问题,正确打印了myBean。。

试了重新加载maven项目、重启IDE,都不行。

解决方法:file-Ivalidate caches-Clear file system cache and Local History