以下是我在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>

解决方案 »

  1.   

    OffsetLimitInterceptor.dialect=com.cacss.framework.core.jdbc.dialect.OracleDialect
    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)
      

  2.   

     No default constructor found; nested exception is java.lang.NoSuchMethodException: 没有默认构造函数。
      

  3.   

    楼主有没有可以运行的spring mvc案例啊,发一个学习学习
    [email protected]谢谢啦
      

  4.   

    SqlSessionFactoryBean  SqlSessionTemplate MapperScannerConfigurer 
    以上三个是MYBATIS 提供的配置。
    mvc确实也配置了构造函数。 那应该怎么配置呢?SPRING3 MVC 注解方式的
      

  5.   


    你是想知道怎么配置 spring mvc的注解吗!还是什么!如果配置注解的 那么你上面的写的bean都可以去掉了直接<context:component-scan base-package="com.**.dao" />直接检索带有@controller @service @Repository @Component等标注的类 
      

  6.   

    springmvc 用注解会简单很多。上手很容易
      

  7.   

    我是想知道 spring mvc的注解版的 mybatis 多数据源配置,最好直接能在spring applactionContext.xml 配置好,而不需要修改程序。因为我用的是spring  mybatis jpetshop框架。 
      

  8.   

    http://download.csdn.net/detail/jiayou55/4853313
      

  9.   

    两个dataSource,两个sqlMapClient,两个sqlMapClientTemplate,dao配置文件配置用哪个sqlMapClient
      

  10.   

    使用构造函数注入
    <bean id="sessionTemplate" class="org.mybatis.spring.SqlSessionTemplate">
      <constructor-arg index="0" ref="sqlSessionFactory" />
    </bean>