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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/27425472/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 04:22:20  来源:igfitidea点击:

The type org.springframework.beans.BeansException cannot be resolved. It is indirectly referenced from required .class files

javajavascripteclipsespringswing

提问by Elavarasan

Hi am facing issue with below error in eclipse please help to resolve this issue.

您好,在 Eclipse 中遇到以下错误,请帮助解决此问题。

Error message

错误信息

The type org.springframework.beans.BeansException cannot be resolved. It is indirectly referenced from required .class files

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

I imported the jar file (org.springframework.context-3.0.4.RELEASE) even then am facing this issue.

我导入了 jar 文件(org.springframework.context-3.0.4.RELEASE),即使我遇到了这个问题。

see below code( where am getting issue at line ApplicationContext appCtx = new ClassPathXmlApplicationContext("applicationContext.xml");)

请参阅下面的代码(在 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);

        }

    }

采纳答案by Ali Dehghani

If you aren't using maven (or any other dependency management tool, for that matter), you should add spring-contextdependencies manually, which are spring-beans, spring-core, spring-aopand spring-expression, of course each of them have their own dependencies either (Transitive Dependency). By the way, BeansExceptionis part of spring-beansmodule

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

回答by kyzh101

May be you are missing org.springframework.beans-3.0.4.RELEASE jar

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

回答by adiarray

Yes I've managed to resolve the issue.... I use the following pattern: the program and the results without error

是的,我已经设法解决了这个问题......我使用以下模式:程序和结果没有错误

Version: 3.0.4.RELEASE

版本:3.0.4.RELEASE

Then select -> Maven-> Update Project

然后选择 -> Maven-> 更新项目

回答by Pichitron

I have problems with *org.springframework.context.EnvironmentAware*
Adding this dependency in pom from maven repository solve my problem.

*<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-beans</artifactId>
    <version>5.0.3.RELEASE</version>
</dependency>*