无法解析org.springframework.beans.BeansException类型.它是从所需的.class文件间接引用的

Ela*_*san 4 javascript java eclipse swing spring

您好在Eclipse中面临以下错误的问题请帮助解决此问题.

错误信息

无法解析org.springframework.beans.BeansException类型.它是从所需的.class文件间接引用的

我导入了jar文件(org.springframework.context-3.0.4.RELEASE),即便面对这个问题.

看下面的代码(在哪里遇到问题ApplicationContext appCtx = new ClassPathXmlApplicationContext("applicationContext.xml");)

    package com.csp.test.document;

    import static org.junit.Assert.*;
    import org.junit.Test;
    import org.springframework.context.ApplicationContext;
    import org.springframework.context.support.ClassPathXmlApplicationContext;

    import com.csp.model.Document;
    import com.csp.service.DocumentService;

    public class DocumentTest {

        @Test
        public void testGetDocument() {
            ApplicationContext appCtx = new ClassPathXmlApplicationContext(
                    "applicationContext.xml");

            DocumentService documentService = (DocumentService) appCtx
                    .getBean("documentService");

            Document doc = documentService.getDocument(1);

            String status = null;

            if (doc != null) {
                status = documentService.saveDocument(doc);
            } else {
                System.out.println("error in retreiving document");
            }

            assertEquals("Success Status", "SUCCESS", status);

        }

    }
Run Code Online (Sandbox Code Playgroud)

Ali*_*ani 16

如果你不使用Maven(或任何其他依赖管理工具,对于这个问题),你应该添加spring-context人工的依赖,这是spring-beans,spring-core,spring-aopspring-expression,当然,他们每个人都有自己的依赖关系是(传递依赖).顺便说一句,BeansExceptionspring-beans模块的一部分


kyz*_*101 6

可能是你缺少 org.springframework.beans-3.0.4.RELEASE jar