我有一个弹簧注射问题,我已经尝试解决 4 天但没有得到任何结果:
在我的春季配置中,我有:
<bean id="applicationCache" class="domain.ui.ApplicationCacheServiceImpl">
<property name="divisionSelectOptionsCache" ref="divisionSelectOptionsCache"/>
</bean>
<bean id="divisionSelectOptionsCache" class="domain.jsf.DivisionSelectOptionsCache"></bean>
ApplicationCacheServiceImpl.scala 看起来像这样:
class ApplicationCacheServiceImpl extends ApplicationCacheService{
var divisionSelectOptionsCache: DivisionSelectOptionsCache = _
def setDivisionSelectOptionsCache(dsoc: DivisionSelectOptionsCache) ={
divisionSelectOptionsCache = dsoc
}
....
DivisionSelectOptionsCache.scala 看起来像这样:
class DivisionSelectOptionsCache extends Converter{
val options = mutable.Map[String, DivisionSelectOption]()
var em: EntityManager = _
// Just left this in case its relevant. Throws no errors though
@PersistenceContext
def setEntityManager(entManager: EntityManager) = {
em = entManager
}
....
应用程序编译并构建了一个战争。但是,当我部署它时,我得到以下异常消息:
INFO: Initializing Spring root WebApplicationContext
Jan 18, 2013 7:56:17 PM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'applicationCache' defined in class path resource
applicationPersistence.xml]: Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException:
Failed to convert property value of type '$Proxy15 implementing javax.faces.convert.Converter,org.springframework.aop.SpringProxy,
org.springframework.aop.framework.Advised' to required type 'com.domain.jsf.DivisionSelectOptionsCache'
for property 'divisionSelectOptionsCache'; nested exception is java.lang.IllegalStateException:
Cannot convert value of type [$Proxy15 implementing javax.faces.convert.Converter,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised]
to required type [com.domain.jsf.DivisionSelectOptionsCache] for property 'divisionSelectOptionsCache': no matching editors or conversion strategy found
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
.....
Caused by: org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type '$Proxy15 implementing javax.faces.convert.Converter,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised' to required type 'com.domain.jsf.DivisionSelectOptionsCache' for property 'divisionSelectOptionsCache'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [$Proxy15 implementing javax.faces.convert.Converter,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised] to required type [com.domain.jsf.DivisionSelectOptionsCache] for property 'divisionSelectOptionsCache': no matching editors or conversion strategy found
at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:485)
at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:516)
....
Caused by: java.lang.IllegalStateException: Cannot convert value of type [$Proxy15 implementing javax.faces.convert.Converter,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised] to required type [com.domain.jsf.DivisionSelectOptionsCache] for property 'divisionSelectOptionsCache': no matching editors or conversion strategy found
at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:247)
at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:470)
... 31 more
Jan 18, 2013 7:56:20 PM org.apache.catalina.core.StandardContext filterStop
FINE: Stopping filters
所以:
ApplicationCacheServiceImpl
正在寻找 spring 来注入属性divisionSelectOptionsCache
,对应的类型DivisionSelectOptionsCache
是正确的,并且在 spring config xml 文件中定义。
上课DivisionSelectOptionsCache
extends
Converter
,所以那里应该没有问题。
所以我被困住了。我什至尝试取出 spring IoC 并使用 google Guice 进行编译时间检查而不是部署时间检查(没有 xml 配置文件),但这不起作用,因为应用程序依赖于 Spring 来提供托管 jsf bean。
请帮忙,因为我快要告诉客户它无法完成。
谢谢