版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
Failed to convert property value of type ‘java.lang.String’ to required type ‘int’ for property ‘maxActive’;
部署好maven项目在tomcat启动报错,各种调试。
我是将所有的项目配置properties文件同一在一个文件中(spring-profile-config.xml),
<!-- 开发环境 -->
<beans profile="dev">
<!-- 开发环境下加载的propertie文件 -->
<bean id="propertyConfigurer" class="com.naturent.pattern.util.PropertyConfigurer">
<property name="locations">
<list>
<value>classpath:profiles/dev/db-config.properties</value>
<value>classpath:profiles/dev/file-url.properties</value>
<value>classpath:profiles/dev/redis.properties</value>
<value>classpath:profiles/dev/weixin.properties</value>
<!-- <value>classpath:profiles/dev/ueditor.properties</value> -->
<!-- <value>classpath:dev/mail-config.properties</value> -->
</list>
</property>
</bean>
</beans>
<!-- 生产环境 -->
<beans profile="prod">
<!-- 生产环境下加载的propertie文件 -->
<bean id="propertyConfigurer" class="com.naturent.pattern.util.PropertyConfigurer">
<property name="locations">
<list>
<value>classpath:profiles/prod/db-config.properties</value>
<value>classpath:profiles/prod/file-url.properties</value>
<value>classpath:profiles/prod/redis.properties</value>
<value>classpath:profiles/prod/weixin.properties</value>
<!-- <value>classpath:profiles/prod/ueditor.properties</value> -->
<!-- <value>classpath:profiles/prod/*.properties</value> -->
<!-- <value>classpath:prod/mail-config.properties</value> -->
</list>
</property>
</bean>
</beans>
目录结果
在web.xml配置
<!-- 读取的配置信息 -->
<context-param>
<param-name>spring.profiles.default</param-name>
<param-value>dev</param-value>
</context-param>
这样配置是正确的,但依旧报错,
后在需要使用properties文件的sprong配置中加入这样一段
<!-- 引入配置文件 -->
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:profiles/dev/db-config.properties</value>
</list>
</property>
</bean>
启动tomcat错误消失,然后删除这段bean配置,再次运行,能够正确读取到统一配置的properties信息。很奇怪。