Error creating bean with name jbpmConfiguration

写了一个spring的jbpmConfiguration

package com.aceway.adf.workflow;

import org.jbpm.JbpmConfiguration;
import org.jbpm.JbpmContext;
import org.jbpm.persistence.db.DbPersistenceServiceFactory;
import org.jbpm.svc.Services;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.InitializingBean;

public class LocalJbpmConfigurationFactoryBean implements InitializingBean,
  DisposableBean, FactoryBean, BeanFactoryAware, BeanNameAware {

 private JbpmConfiguration jbpmConfiguration;

 private String contextName = JbpmContext.DEFAULT_JBPM_CONTEXT_NAME;

 public void destroy() throws Exception {
  if (jbpmConfiguration != null) {
   jbpmConfiguration.close();
  }
 }

 /**
  * FactoryLocator
  */
 private JbpmFactoryLocator factoryLocator = new JbpmFactoryLocator();

 /**
  * @see org.springframework.beans.factory.BeanFactoryAware#setBeanFactory(org.springframework.beans.factory.BeanFactory)
  */
 public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
  factoryLocator.setBeanFactory(beanFactory);

 }

 /**
  * @see org.springframework.beans.factory.BeanNameAware#setBeanName(java.lang.String)
  */
 public void setBeanName(String name) {
  factoryLocator.setBeanName(name);
 }

 public void afterPropertiesSet() throws Exception {
  jbpmConfiguration = JbpmConfiguration.getInstance();
  DbPersistenceServiceFactory dbPersistenceServiceFactory = (DbPersistenceServiceFactory) jbpmConfiguration
    .getServiceFactory(Services.SERVICENAME_PERSISTENCE);
 }

 /**
  * @see org.springframework.beans.factory.FactoryBean#getObject()
  */
 public Object getObject() throws Exception {
  return jbpmConfiguration;
 }

 /**
  * @see org.springframework.beans.factory.FactoryBean#getObjectType()
  */
 public Class getObjectType() {
  return JbpmConfiguration.class;
 }

 /**
  * @see org.springframework.beans.factory.FactoryBean#isSingleton()
  */
 public boolean isSingleton() {
  return true;
 }

 public String getContextName() {
  return contextName;
 }

 public void setContextName(String contextName) {
  this.contextName = contextName;
 }
}

 

在配制文件里写入

<bean id="jbpmConfiguration" class="com.aceway.adf.workflow.LocalJbpmConfigurationFactoryBean"></bean>

 

 <bean id="jbpmAdminServices" class="com.aceway.adf.workflow.service.AdminServicesImpl">
  <property name="jbpmConfiguration">
   <ref bean="jbpmConfiguration" />
  </property>
 </bean>

 

在java文件里写入

private JbpmConfiguration jbpmConfiguration;

 

 public JbpmConfiguration getJbpmConfiguration() {
  return jbpmConfiguration;
 }

 public void setJbpmConfiguration(JbpmConfiguration jbpmConfiguration) {
  this.jbpmConfiguration = jbpmConfiguration;
 }

 

这样的话tomcat是可以起来的.但是一执行页面的时候,就会出现

 Error creating bean with name 'jbpmConfiguration' defined in ServletContext resource [/WEB-INF/workflowsystem-servlet.xml]

 

问题正待解决...............

 

-----------------------------------------------------------------------------

问题已经解决

主要是因为在workflowsystem-servlet.xml文件里写成<beans default-autowire="autodetect">将它去掉就可以了.

So far you’ve seen how to wire all of your bean’s properties explicitly using the <property> element. Alternatively, you can have Spring wire them automatically autowire property on each <bean> that you want autowired:

 

default-autowire有四种属性:

byName—Attempts to find a bean in the container whose name (or ID) is the same as the name of the property being wired. If a matching bean is not found, then the property will remain unwired.
byType—Attempts to find a single bean in the container whose type matches the type of the property being wired. If no matching bean is found, then the property will not be wired. If more than one bean matches, an org.springrframework.beans.factory.UnsatisfiedDependencyExcpetion will be thrown.
constructor—Tries to match up one or more beans in the container with the parameters of one of the constructors of the bean being wired. In the event of ambiguous beans or ambiguous constructors, an
org.springframework.beans.factory.UnsatisfiedDependencyException will be thrown.
autodetect—Attempts to autowire by constructor first and then using
byType. Ambiguity is handled the same way as with constructor and
byType wiring.

摘自<<spring in action>>

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值