【发布时间】:2017-09-07 13:48:11
【问题描述】:
我正在尝试为 activiti 中的一个简单进程运行单元测试,但我不断收到异常。我已经搜索并相信问题出在 activiti.cfg.xml 文件本身,它需要一个构造函数,但它有一个属性。测试是自动生成的,activiti.cfg.xml 文件也是如此。所以我想知道我应该改变什么才能让它工作。
这是xml文件:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="processEngineConfiguration" class="org.activiti.engine.impl.cfg.StandaloneInMemProcessEngineConfiguration">
<property name="databaseSchemaUpdate" value="true"/>
</bean>
</beans>
这是错误:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'processEngineConfiguration' defined in class path resource [activiti.cfg.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.activiti.engine.impl.cfg.StandaloneInMemProcessEngineConfiguration]: No default constructor found; nested exception is java.lang.NoClassDefFoundError: org/apache/ibatis/type/TypeHandler
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1228)
【问题讨论】:
-
你会添加
StandaloneInMemProcessEngineConfiguration类的来源吗?它有默认构造函数吗? -
StandaloneInMemProcessEngineConfiguratio 类在 org.activiti.engine.impl.cfg 包中。这是代码
-
包 org.activiti.engine.impl.cfg; /** */ 公共类 StandaloneInMemProcessEngineConfiguration 扩展 StandaloneProcessEngineConfiguration { public StandaloneInMemProcessEngineConfiguration() { this.databaseSchemaUpdate = DB_SCHEMA_UPDATE_CREATE_DROP; this.jdbcUrl = "jdbc:h2:mem:activiti"; } }
-
您的主要例外是:
java.lang.NoClassDefFoundError: org/apache/ibatis/type/TypeHandler所以@Faron 的答案可能是正确的。
标签: java xml eclipse junit4 activiti