The org.springframework.beans.BeansException type could not be resolved. This indirectly refers to the required .class files

Hi i am facing problem with below error in eclipse please help to solve this problem.

Error message

The org.springframework.beans.BeansException type could not be resolved. This indirectly links to the required .class files

I imported the jar file (org.springframework.context-3.0.4.RELEASE) even then ran into this problem.

see below code (where i am getting error at ApplicationContext line appCtx = new ClassPa thanks mlApplicationContext ("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);

        }

    }

      

+3


source to share


4 answers


If you do not use maven (or any other dependency management tool, for that matter), you must manually add spring-context

dependencies spring-beans

, spring-core

, spring-aop

and spring-expression

, of course, each of them has its own dependencies (Transitive Dependency). By the way, BeansException

is part of the modulespring-beans



+12


source


You may be missing the org.springframework.beans-3.0.4.RELEASE jar



+4


source


Yes I managed to solve the problem .... I am using the following pattern: program and results without errors

Version: 3.0.4.RELEASE

Then select -> Maven-> Update Project

+2


source


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>*

      

0


source







All Articles