Exception in thread "main" java.lang.NoSuchMethodError: org.springframework.beans.factory.xml.XmlBean

新建了一个maven 项目 测试 spring 连接数据库时报错

Exception in thread "main" java.lang.NoSuchMethodError: org.springframework.beans.factory.xml.XmlBean

代码为

public class Login {
public static void main(String[] args) {
String location="dateSource.xml";
ApplicationContext context=new ClassPathXmlApplicationContext(location);
UserDaoImpl studentDaoImp = (UserDaoImpl)context.getBean("studentDaoImp");

}}

一般来说NoSuchMethodError 的错误为 maven中jar包的版本不一致 或者 maven仓库 中有两个版本的jar包

我的maven仓中spring  jar包为1.2.6的版本其中spring-beans的为1.2.3后来改为1.2.6  在测试不报这个错了

猜你喜欢

转载自www.cnblogs.com/zjf6666/p/9077598.html