以下是我在spring applactionContext.xml的配置<context:property-placeholder location="classpath:jdbc.properties"/> <bean id="dataSourceSpied" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="${jdbc.driverClassName}"/>
<property name="url" value="${jdbc.url}"/>
<property name="username" value="${jdbc.username}"/>
<property name="password" value="${jdbc.password}"/>
<property name="maxActive" value="${pool.maxActive}" />
<property name="maxIdle" value="${pool.maxIdle}" />
<property name="minEvictableIdleTimeMillis" value="${pool.minEvictableIdleTimeMillis}" />
<property name="timeBetweenEvictionRunsMillis" value="${pool.timeBetweenEvictionRunsMillis}" />
</bean> <bean id="dataSource" class="net.sf.log4jdbc.Log4jdbcProxyDataSource">
<constructor-arg ref="dataSourceSpied" />
</bean> <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean>
<bean id="sessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="configLocation" value="classpath:mybatis/configuration.xml"/>
<!--property name="mapperLocations" value="com.cacss.payment.platform.*.persistence/*.xml" /-->
</bean>
<bean id="sessionTemplate" class="org.mybatis.spring.SqlSessionTemplate">
<property name="sqlSessionFactoryName" value="sessionFactory" />
</bean>
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="com.cacss.payment.platform.*.persistence" />
<property name="sqlSessionTemplateBeanName" value="sessionTemplate" />
</bean>
<property name="driverClassName" value="${jdbc.driverClassName}"/>
<property name="url" value="${jdbc.url}"/>
<property name="username" value="${jdbc.username}"/>
<property name="password" value="${jdbc.password}"/>
<property name="maxActive" value="${pool.maxActive}" />
<property name="maxIdle" value="${pool.maxIdle}" />
<property name="minEvictableIdleTimeMillis" value="${pool.minEvictableIdleTimeMillis}" />
<property name="timeBetweenEvictionRunsMillis" value="${pool.timeBetweenEvictionRunsMillis}" />
</bean> <bean id="dataSource" class="net.sf.log4jdbc.Log4jdbcProxyDataSource">
<constructor-arg ref="dataSourceSpied" />
</bean> <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean>
<bean id="sessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="configLocation" value="classpath:mybatis/configuration.xml"/>
<!--property name="mapperLocations" value="com.cacss.payment.platform.*.persistence/*.xml" /-->
</bean>
<bean id="sessionTemplate" class="org.mybatis.spring.SqlSessionTemplate">
<property name="sqlSessionFactoryName" value="sessionFactory" />
</bean>
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="com.cacss.payment.platform.*.persistence" />
<property name="sqlSessionTemplateBeanName" value="sessionTemplate" />
</bean>
解决方案 »
- 几个关于struts2和spring注解的问题
- 求一个好简单的select控件的用法
- struts2 和jasperreport产生excel的问题
- 关于用户权限的问题
- 怎样解决网页中传值时出现乱码问题
- 为什么运行不过这句呢??
- 请问我如何知道自己的jsp,servlet,taglib等等是什么版本的
- 如何取出当前时间与中午12点判断?
- 如何在JSP和Servlet中实现forward功能? 50分相送!
- httpclient抓取页面返回信息不全
- MultiLine组件问题
- AXIS error java.lang.NoClassDefFoundError: HTTPClient/ModuleException
2012-12-05 22:44:42,849 DEBUG [org.mybatis.spring.SqlSessionFactoryBean] -Parsed configuration file: 'class path resource [mybatis/configuration.xml]'
2012-12-05 22:44:44,943 DEBUG [org.mybatis.spring.SqlSessionFactoryBean] -Property 'mapperLocations' was not specified or no matching resources found
2012-12-05 22:44:44,954 INFO [org.springframework.beans.factory.support.DefaultListableBeanFactory] -Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@b0ede5: defining beans [org.springframework.aop.config.internalAutoProxyCreator,org.springframework.aop.aspectj.AspectJPointcutAdvisor#0,logPoint,LogAop,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0,org.springframework.transaction.interceptor.TransactionInterceptor#0,org.springframework.transaction.config.internalTransactionAdvisor,org.springframework.context.support.PropertySourcesPlaceholderConfigurer#0,dataSourceSpied,dataSource,transactionManager,sessionFactory,sessionTemplate,org.mybatis.spring.mapper.MapperScannerConfigurer#0,org.springframework.context.annotation.ConfigurationClassPostProcessor$ImportAwareBeanPostProcessor#0,taccountMapper,accountMapper]; root of factory hierarchy
2012-12-05 22:44:44,955 ERROR [org.springframework.web.context.ContextLoader] -Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionTemplate' defined in class path resource [applicationContext.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.mybatis.spring.SqlSessionTemplate]: No default constructor found; nested exception is java.lang.NoSuchMethodException: org.mybatis.spring.SqlSessionTemplate.<init>()
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:997)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:943)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485)
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)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:385)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:284)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4206)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4705)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
at org.apache.catalina.core.StandardService.start(StandardService.java:525)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.mybatis.spring.SqlSessionTemplate]: No default constructor found; nested exception is java.lang.NoSuchMethodException: org.mybatis.spring.SqlSessionTemplate.<init>()
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:72)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:990)
... 28 more
Caused by: java.lang.NoSuchMethodException: org.mybatis.spring.SqlSessionTemplate.<init>()
at java.lang.Class.getConstructor0(Class.java:2706)
at java.lang.Class.getDeclaredConstructor(Class.java:1985)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:67)
... 29 more
2012-12-5 22:44:44 org.apache.catalina.core.StandardContext listenerStart
严重: 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 'sessionTemplate' defined in class path resource [applicationContext.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.mybatis.spring.SqlSessionTemplate]: No default constructor found; nested exception is java.lang.NoSuchMethodException: org.mybatis.spring.SqlSessionTemplate.<init>()
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:997)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:943)
[email protected]谢谢啦
以上三个是MYBATIS 提供的配置。
mvc确实也配置了构造函数。 那应该怎么配置呢?SPRING3 MVC 注解方式的
你是想知道怎么配置 spring mvc的注解吗!还是什么!如果配置注解的 那么你上面的写的bean都可以去掉了直接<context:component-scan base-package="com.**.dao" />直接检索带有@controller @service @Repository @Component等标注的类
<bean id="sessionTemplate" class="org.mybatis.spring.SqlSessionTemplate">
<constructor-arg index="0" ref="sqlSessionFactory" />
</bean>