java - 无法转换 JndiRmiProxyFactoryBean 类型的值 找不到匹配的编辑器或转换策略
问题描述
在我的项目中,我配置了 spring bean 如下。(获得DataSource
通过JNDI
)。当我spring 3.2.5
与hibernate 4
.
<bean id="dataSource" class="org.springframework.remoting.rmi.JndiRmiProxyFactoryBean">
<property name="jndiName" value="java:/jdbc/mydb"/>
<property name="serviceInterface" value="javax.sql.DataSource"/>
</bean>
<bean id="sessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean" scope="singleton">
<property name="dataSource" ref="dataSource"/>
<property name="packagesToScan" value="com.abc.core.system_configuration.implGeneral.bean.*"/>
<property name="configLocations" value="implGeneral/sysConfigHibernate.cfg.xml"/>
</bean>
但是,现在当我尝试将 Spring 更新到 5.1.8 和 Hibernate 5 时,出现以下错误。
Initialization of bean failed;
nested exception is org.springframework.beans.ConversionNotSupportedException:
Failed to convert property value of type 'org.springframework.remoting.rmi.JndiRmiProxyFactoryBean' to required type 'javax.sql.DataSource' for property 'dataSource';
nested exception is java.lang.IllegalStateException: Cannot convert value of type 'org.springframework.remoting.rmi.JndiRmiProxyFactoryBean' to required type 'javax.sql.DataSource' for property 'dataSource': no matching editors or conversion strategy found.
为什么org.springframework.remoting.rmi.JndiRmiProxyFactoryBean
不能投到javax.sql.DataSource
。有人对此有想法吗?
更新:完整的错误日志如下
13:59:30,939 ERROR [org.springframework.web.context.ContextLoader] Context initialization failed:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'springSecurityFilterChain' defined in class path resource [org/springframework/security/config/annotation/web/configuration/WebSecurityConfiguration.class]: Bean instantiation via factory method failed;
nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.servlet.Filter]: Factory method 'springSecurityFilterChain' threw exception;
nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ruleCacheControler' defined in class path resource [implGeneral/spring-config-systemconfig.xml]: Cannot resolve reference to bean 'ruleHibernatePersister' while setting constructor argument;
nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ruleHibernatePersister' defined in class path resource [implGeneral/spring-config-systemconfig.xml]: Cannot resolve reference to bean 'sessionFactory' while setting constructor argument;
nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [implGeneral/spring-config-systemconfig.xml]: Initialization of bean failed;
nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'org.springframework.remoting.rmi.JndiRmiProxyFactoryBean' to required type 'javax.sql.DataSource' for property 'dataSource';
nested exception is java.lang.IllegalStateException: Cannot convert value of type 'org.springframework.remoting.rmi.JndiRmiProxyFactoryBean' to required type 'javax.sql.DataSource' for property 'dataSource': no matching editors or conversion strategy found
解决方案
推荐阅读
- .net - 使用 SSIS 包通过 SQL 服务器更新开发应用程序的正确方法
- cgroups - 找不到 cgroup V2 控制器
- spring-boot - 我是否需要在消息传输过程中进行身份验证
- nsis - 目标文件夹中的路径附加到旧路径,而不是使用 NSIS 显示新路径
- pentaho - Pentaho cde 弹出窗口不显示表格
- django - 我在 models.py 中的 datetime 字段不起作用,即使它在迁移时没有引发任何异常
- python - pip 在安装包时出现冲突错误
- postgresql - 如何使用 JMeter 中的 JDBC 请求将 Database1 中的值列表与 Database2 中的列匹配?
- angular - Firestore 集合展平 Observable
> - android - 设备 RAM 增加后,Android sharedpreferences 被清除