SSM整合无法解析$解决方案

来源:互联网 发布:amd自动超频软件 编辑:程序博客网 时间:2024/06/01 17:33

在进行Spring+SpringMVC+MyBatis的整合过程中,遇到$符号无法解析

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.mybatis.spring.mapper.MapperScannerConfigurer#0' defined in class path resource [applicationContext.xml]: Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Cannot resolve reference to bean 'dataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [applicationContext.xml]: Initialization of bean failed; nested exception is org.springframework.beans.TypeMismatchException: Failed to convert property value of type 'java.lang.String' to required type 'int' for property 'maxPoolSize'; nested exception is java.lang.NumberFormatException: For input string: "${jdbc.maxsize}"    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:359)    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:108)    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1531)    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1276)    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553)    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)    at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:115)    at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:686)    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:524)    at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:443)    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:325)    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107)    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4811)    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5251)    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1408)    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1398)    at java.util.concurrent.FutureTask.run(Unknown Source)    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)    at java.lang.Thread.run(Unknown Source)

原因是:

<!--配置扫描  -->    <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">    <property name="basePackage" value="org.qf.dao"></property>    <property name="sqlSessionFactory" ref="sessionFactory"></property>    </bean>

就在配置的扫描类这有问题,只需将sqlSessionFactory删除掉即可。

<!--配置扫描  -->    <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">    <property name="basePackage" value="org.qf.dao"></property>    </bean>