问题描述
错误消息
无法解析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);
文档doc = documentService.getDocument(1);
String status = null;
if(doc!= null){
status = documentService.saveDocument(doc);
} else {
System.out.println(retreiving document中的错误);
}
assertEquals(成功状态,SUCCESS,状态);
}
}
如果您不使用maven(或任何其他依赖关系管理工具),则应手动添加 spring-context
依赖关系是 spring-beans
, spring-core
, spring-aop
和 spring-expression
,当然每个都有自己的依赖关系(传递依赖关系)。顺便说一下, BeansException
是 spring-beans
模块
的一部分
Hi am facing issue with below error in eclipse please help to resolve this issue.
Error message
The type org.springframework.beans.BeansException cannot be resolved. It is indirectly referenced from required .class files
I imported the jar file (org.springframework.context-3.0.4.RELEASE) even then am facing this issue.
see below code( where am getting issue at line 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);
}
}
If you aren't using maven (or any other dependency management tool, for that matter), you should add spring-context
dependencies manually, which are spring-beans
, spring-core
, spring-aop
and spring-expression
, of course each of them have their own dependencies either (Transitive Dependency). By the way, BeansException
is part of spring-beans
module
这篇关于无法解析org.springframework.beans.BeansException类型。它是从所需的.class文件间接引用的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!