线程“主”中的异常java.lang.NoClassDefFoundError:org / springframework / asm / commons / EmptyVisitor

时间:2019-06-22 08:35:43

标签: spring

我已经使用xml文件,Car类和具有main方法的Client类构建了我的First Spring程序。这些类中没有错误,我在xml文件的bean标记中使用了xml名称空间,但是在运行Client.java程序时遇到了以下错误。

''' Exception in thread "main" java.lang.NoClassDefFoundError:

org / springframework / asm / commons / EmptyVisitor'''

'''java

// Car.java
package Class_DI;

public class Car {

public String carname;

public String getCarname() {
    System.out.println("Car name is: " + carname);
    return carname;
}

public void setCarname(String carname) {
    this.carname = carname;
}

}

// eof '''

'''xml //Spring.xml      http://www.springframework.org/dtd/spring-beans.dtd“>?>

 <beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:context="http://www.springframework.org/schema/context"
   xsi:schemaLocation="http://www.springframework.org/schema/beans
       http://www.springframework.org/schema/beans/spring-beans-3.2.1.xsd
       http://www.springframework.org/schema/context
       http://www.springframework.org/schema/context/spring-context-3.2.1.xsd">

<bean id='c' classname="Class_DI.Car" />
<property name="carname" value="Santro Zing" />


  </beans>

''' // eof

'''java // Client.java     包Class_DI;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import Class_DI.Car;

 public class Client {

public static void main(String[] args) {

    ApplicationContext ap = new ClassPathXmlApplicationContext("Spring.xml");       
    Object o = ap.getBean("c");
    Car c = (Car)o;
    c.getCarname();

}
 }

''' // eof

请帮助我完成我的Spring计划。

输出应类似于:汽车名称:Santro Zing

0 个答案:

没有答案