“The constructor ClassPathXmlApplicationContext(String) refers to the missing type BeansException”
“構造函數ClassPathXmlApplicationContext(字符串)是指缺失類型BeansException”
出現錯誤的原因:jar沒有正確引入,即使表面上你能import包。
import org.junit.Test; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext;
如果你用的eclipes解決 方案:
進入你的maven倉庫,本地的,刪除關於spring-core,spring-context,刪除了之后,讓工具重新下載一下
然后update maven一下 就ok了

package zy.test; import org.junit.Test; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; public class TestUser { @Test public void Test(){ ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml"); } }
---哦了
