Junit测试报错

灯火-阑珊 2012-08-13 11:40:57
使用junit测试报错求解决
java.lang.IllegalStateException: Failed to load ApplicationContext
at org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:308)

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'activateTablesService': Injection of autowired dependencies failed;

nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private

com.supporter.prj.bm.budgeteering.service.BudgeteeringTableService com.supporter.prj.bm.budgeteering.service.ActivateTablesService.budgeteeringTableService; nested

exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'budgeteeringTableService': Injection of autowired dependencies

failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private

com.supporter.prj.bm.budgeteering.service.BudgeteeringTableRecService com.supporter.prj.bm.budgeteering.service.BudgeteeringTableService.budgeteeringTableRecService;

nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'budgeteeringTableRecService': Injection of autowired

dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private

com.supporter.prj.bm.budgeteering.service.BudgeteeringTableService com.supporter.prj.bm.budgeteering.service.BudgeteeringTableRecService.budgeteeringTableService;

nested exception is java.lang.NoSuchMethodError: org.objectweb.asm.ClassWriter.<init>(Z)V

Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private

com.supporter.prj.bm.budgeteering.service.BudgeteeringTableService com.supporter.prj.bm.budgeteering.service.ActivateTablesService.budgeteeringTableService; nested

exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'budgeteeringTableService': Injection of autowired dependencies

failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private

com.supporter.prj.bm.budgeteering.service.BudgeteeringTableRecService com.supporter.prj.bm.budgeteering.service.BudgeteeringTableService.budgeteeringTableRecService;

nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'budgeteeringTableRecService': Injection of autowired

dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private

com.supporter.prj.bm.budgeteering.service.BudgeteeringTableService com.supporter.prj.bm.budgeteering.service.BudgeteeringTableRecService.budgeteeringTableService;

nested exception is java.lang.NoSuchMethodError: org.objectweb.asm.ClassWriter.<init>(Z)V
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject

(AutowiredAnnotationBeanPostProcessor.java:502)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:84)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:282)
... 38 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'budgeteeringTableService': Injection of autowired dependencies

failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private

com.supporter.prj.bm.budgeteering.service.BudgeteeringTableRecService com.supporter.prj.bm.budgeteering.service.BudgeteeringTableService.budgeteeringTableRecService;

nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'budgeteeringTableRecService': Injection of autowired

dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private

com.supporter.prj.bm.budgeteering.service.BudgeteeringTableService com.supporter.prj.bm.budgeteering.service.BudgeteeringTableRecService.budgeteeringTableService;

nested exception is java.lang.NoSuchMethodError: org.objectweb.asm.ClassWriter.<init>(Z)V

Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private

com.supporter.prj.bm.budgeteering.service.BudgeteeringTableRecService com.supporter.prj.bm.budgeteering.service.BudgeteeringTableService.budgeteeringTableRecService;

nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'budgeteeringTableRecService': Injection of autowired

dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private

com.supporter.prj.bm.budgeteering.service.BudgeteeringTableService com.supporter.prj.bm.budgeteering.service.BudgeteeringTableRecService.budgeteeringTableService;

nested exception is java.lang.NoSuchMethodError: org.objectweb.asm.ClassWriter.<init>(Z)V
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject

(AutowiredAnnotationBeanPostProcessor.java:502)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:84)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:282)
... 51 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'budgeteeringTableRecService': Injection of autowired dependencies

failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private

com.supporter.prj.bm.budgeteering.service.BudgeteeringTableService com.supporter.prj.bm.budgeteering.service.BudgeteeringTableRecService.budgeteeringTableService;

nested exception is java.lang.NoSuchMethodError: org.objectweb.asm.ClassWriter.<init>(Z)V

... 53 more
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private

com.supporter.prj.bm.budgeteering.service.BudgeteeringTableService com.supporter.prj.bm.budgeteering.service.BudgeteeringTableRecService.budgeteeringTableService;

nested exception is java.lang.NoSuchMethodError: org.objectweb.asm.ClassWriter.<init>(Z)V
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject

(AutowiredAnnotationBeanPostProcessor.java:502)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:84)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:282)
... 64 more
Caused by: java.lang.NoSuchMethodError: org.objectweb.asm.ClassWriter.<init>(Z)V

...全文
174 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
灯火-阑珊 2012-08-13
  • 打赏
  • 举报
回复
package com.supporter.prj.bm.budgeteering.service;

import java.util.List;
import java.util.StringTokenizer;

import javax.servlet.jsp.JspWriter;
import org.springframework.beans.factory.annotation.Autowired;
import com.supporter.prj.bm.budgeteering.entity.BudgeteeringTable;
import com.supporter.prj.bm.service.BMService;
import com.supporter.prj.bm.service.budget_template.IBudgetTemplate;
import com.supporter.prj.log4j.XLogger;
import com.supporter.security.UserProfile;
import com.supporter.util.CommonUtil;

/**
* 批量启用预算表的Service类.
* @author Libin
*/
public class ActivateTablesService{
@Autowired
private BudgeteeringTableService budgeteeringTableService;

/**
* 获取指定部门的所有已生效(包括执行中的)的表格的所属模板的编号.
* @param deptId
* @param budgetYear
* @return
*/
@SuppressWarnings("unchecked")
public List < String > getEffectiveTableTemplateNos(int budgetYear,String deptId) {
List < String > templateNos = budgeteeringTableService.
getEffectiveTableTemplateNos(budgetYear,deptId);
return templateNos;
}

/**
* 根据模板编号获取已生效(包括执行中的)的预算表.
* @param templateNo
* @param deptId
* @param budgetYear
* @return
*/
@SuppressWarnings("unchecked")
public List < BudgeteeringTable > getEffectiveTablesByTemplateNo(int budgetYear,String templateNo,
String deptId) {
List < BudgeteeringTable > tables = budgeteeringTableService.
getEffectiveTablesByTemplateNo(budgetYear,templateNo,deptId);
return tables;
}

/**
* 根据模板编号获取模板名.
* @param templateNo
* @param budgetYear
* @return
*/
public String getTemplateNameByNo(int budgetYear,String templateNo) {
IBudgetTemplate template =
BMService.getBudgetTemplateService().getBudgetTemplateByNo(budgetYear,templateNo);
if (template == null) {
XLogger.getLogger().debug("failed to getTemplate By templateNo");
return null;
} else {
return CommonUtil.trim(template.getTemplateName());
}
}

/**
* 批量激活预算表.
* @param selectedTableIds 预算表的Ids,相互间用","隔开
* @param budgetYear
* @param writer
* @param userProfile
*/
public void activateTables(int budgetYear,String selectedTableIds,
UserProfile userProfile, JspWriter writer) {
StringTokenizer tableIs = new StringTokenizer(selectedTableIds, ",");
while (tableIs.hasMoreElements()) {
String tableId = CommonUtil.trim((String)tableIs.nextElement());
if (tableId.length() == 0) continue;

BudgeteeringTable table = budgeteeringTableService.getBudgeteeringTable(budgetYear,tableId);
if (table == null) continue;
budgeteeringTableService.activateTable(budgetYear,table, userProfile, writer);
}
}

/**
* 批量预启用预算表.
* @param selectedTableIds 预算表的Ids,相互间用","隔开
* @param userProfile
* @param writer
* @param budgetYear
*/
public void preactivateTables(int budgetYear,String selectedTableIds,
UserProfile userProfile, JspWriter writer) {
StringTokenizer tableIs = new StringTokenizer(selectedTableIds, ",");
while (tableIs.hasMoreElements()) {
String tableId = CommonUtil.trim((String)tableIs.nextElement());
if (tableId.length() == 0) continue;

BudgeteeringTable table = budgeteeringTableService.getBudgeteeringTable(budgetYear,tableId);
if (table == null) continue;

budgeteeringTableService.preactivateTable(budgetYear,table, userProfile, writer);
}
}

/**
* 批量启用预算表的结构(不包括预算值).
* @param selectedTableIds 预算表的Ids,相互间用","隔开
* @param writer
* @param userProfile
* @param budgetYear
*/
public void activateTableStructures(int budgetYear,String selectedTableIds,
UserProfile userProfile, JspWriter writer) {
StringTokenizer tableIs = new StringTokenizer(selectedTableIds, ",");
while (tableIs.hasMoreElements()) {
String tableId = CommonUtil.trim((String)tableIs.nextElement());
if (tableId.length() == 0) continue;
BudgeteeringTable table = budgeteeringTableService.getBudgeteeringTable(budgetYear,tableId);
if (table == null) continue;
budgeteeringTableService.activateTableStructure(budgetYear,table, userProfile, writer);
}
}
}
  • 打赏
  • 举报
回复
注入失败啊,你用的是自动扫描注解?
Sammie 2012-08-13
  • 打赏
  • 举报
回复
加载Spring文件失败?

把你这个Junit方法贴下呗。

81,095

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧