Java BeanException在IDE中未正确解析

Java BeanException在IDE中未正确解析,java,spring,intellij-idea,Java,Spring,Intellij Idea,守则: import org.springframework.beans.BeansException; import org.springframework.context.support.ClassPathXmlApplicationContext; public class Hello { private String s; public Hello(String str){ s = str; } public void sayHi()

守则:

import org.springframework.beans.BeansException;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class Hello {
    private String s;

    public Hello(String str){
        s = str;
    }

    public void sayHi(){
        System.out.println(s);
    }

    public static void main(String []args){
        ClassPathXmlApplicationContext ac = null;//
        try {
            ac = new ClassPathXmlApplicationContext(new String[] {"config.xml"});
            Hello h = (Hello) ac.getBean("hello");//
            h.sayHi();
        } catch (BeansException e) {
            e.printStackTrace();  
        }
    }
}
IntelliJ Idea标记为红色的问题:

这很奇怪,因为豆子的特殊性来自于抛弃:
原因是什么?如何修复?

尝试重建项目。代码是有效的,应该编译。您使用的IDEA版本一定有问题,当它无法正确解释代码时,它会处于某种状态。

如果您构建项目会发生什么?谢谢。这是个好问题。我已经安装了maven并进行了干净的安装,一切正常。似乎问题只存在于IntelliJ IDE。我发布了我的评论作为答案,因为它解决了您的问题。