2013-08-30 13 views
3

代碼:BeanException沒有在理念IDE correcte解決

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標誌着紅問題: enter image description here

這很奇怪,因爲BeansException是Throwable inhertis: http://static.springsource.org/spring/docs/2.0.2/api/org/springframework/beans/BeansException.html 什麼原因和熱修復?謝謝。

+1

如果你建立你的項目會發生什麼? – Magnilex

+0

謝謝。這是個好問題。我已經安裝了maven,並進行了乾淨的安裝,一切正常。似乎只有IntelliJ IDE的問題。 – user710818

+0

我發表了我的評論作爲答案,因爲它解決了你的問題。 – Magnilex

回答

1

嘗試重建項目。該代碼是有效的,應該編譯。您正在使用的IDEA版本必須存在問題,無論如何,它在無法正確解釋代碼時處於一種狀態。