【发布时间】:2015-02-10 02:11:55
【问题描述】:
您好,在 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);
}
}
【问题讨论】:
-
这个jar需要存在于依赖中。
标签: java javascript eclipse spring swing