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

标签 java javascript eclipse spring swing

您好,我在 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);

        }

    }

最佳答案

如果你没有使用 maven(或任何其他依赖管理工具,就此而言),你应该手动添加 spring-context 依赖,它们是 spring-beansspring-corespring-aopspring-expression,当然它们各自都有自己的依赖(Transitive Dependency)。顺便说一句,BeansExceptionspring-beans 模块的一部分

关于java - 无法解析类型 org.springframework.beans.BeansException。它是从所需的 .class 文件中间接引用的,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27425472/

相关文章:

java - JTextField 上的 TitledBorder

java - 安卓本地化

javascript - 密码不应以数字开头

javascript - matchMedia.js 是否需要 respond.js 才能在旧版 IE 浏览器中工作

java - 截断二进制对数

eclipse - 从 Eclipse 在 Tomcat 上运行 Maven 项目

java - 在一个项目中混合 java、scala 和 xtend 文件?

java - 比较输出流性能

java - rJava 无法安装在 openSUSE 13.2 上

javascript - 使用 map 函数 div 到数组中