【发布时间】:2011-03-02 00:06:34
【问题描述】:
我已将 Eclipse 配置为使用外部 maven 实例。尽管如此,我有一个从命令行运行良好的集成测试,但在 Eclipse 中却失败了。该错误是一个类 Spring 应用程序上下文 bean 错误:
Cannot convert value of type [java.lang.String] to required type
罪魁祸首是一个使用 PropertyPlaceholderConfigurer 设置属性值的 bean。
<!-- property settings for non-JNDI database connections -->
<bean id="placeholderConfigUuid" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE" />
<property name="location" value="classpath:database.properties" />
<property name="placeholderPrefix" value="$DS{" />
</bean>
我知道哪个 bean 失败了,因为它出现在堆栈跟踪中,并且当我将 $DS{hibernate.dialect} 替换为静态值时它可以工作。
编辑:这里是使用属性值的地方:
<bean id="myTestLocalEmf" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="persistenceUnitName" value="myapp-core" />
.......ommitted for brevity.......
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="showSql" value="true" />
<!-- The following use the PropertyPlaceholderConfigurer but it doesn't work in Eclipse -->
<property name="database" value="$DS{hibernate.database}" />
<property name="databasePlatform" value="$DS{hibernate.dialect}" />
</bean>
</property>
</bean>
我有两个问题:
1) 由于 M2Eclipse 使用与命令行相同的 Maven 设置,为什么一个工作而另一个失败? 2)如何解决这个问题?我真的很喜欢在 Eclipse 中按需运行单个 jUnit 测试的能力。
【问题讨论】:
标签: eclipse spring configuration maven-2 junit