user710818
user710818

Reputation: 24248

BeanException is not correctly resolved in Idea IDE

the code:

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();  
        }
    }
}

The problem that IntelliJ Idea marks red:
enter image description here

It is strange because BeansException inhertis from Throwable: http://static.springsource.org/spring/docs/2.0.2/api/org/springframework/beans/BeansException.html What the reason and how to fix?

Upvotes: 3

Views: 255

Answers (1)

Magnilex
Magnilex

Reputation: 11958

Try rebuilding the project. The code is valid and should compile. There must be a problem with the IDEA version you are using, somehow it gets in a state when it cannot correctly interpret the code.

Upvotes: 2

Related Questions