如何在春天解决我的BeansException

时间:2016-02-21 18:42:22

标签: spring

我是spring技术的新手。我正在尝试使用j2ee容器创建简单的spring独立应用程序。

为此我添加了4个jar文件。

1)commons-loggins-1.3 jar
2)spring_bean_3.0.5
3)spring_core_3.0.0
4)Spring_context_3.0.2

我想在我的客户端类中创建应用程序上下文实例。我遇到了以下错误。

Exception in thread "main" java.lang.Error: Unresolved compilation problems: 
    The type org.springframework.beans.BeansException cannot be resolved. It is indirectly referenced from required .class files
    The constructor ClassPathXmlApplicationContext(String) refers to the missing type BeansException

    at test.Core_J2ee_Client.main(Core_J2ee_Client.java:12)

这是我的代码。

这是我的客户端类。

package test;

import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import beans.Test;

public class Core_J2ee_Client {

    public static void main(String[] args) {

        ConfigurableApplicationContext ap = new ClassPathXmlApplicationContext("resource/spring.xml");

    }

}

这是我的pojo课程。

package beans;

public class Test {

    public Test(){
        System.out.println("this is test cons---");
    }
    public void hello(){
        System.out.println("this is hello method");
    }
}

这是我的spring.xml文件。

<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"  
        "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<bean id="t" class="beans.Test">
</bean>

</beans>

0 个答案:

没有答案