小土豆子额 2016-10-15 13:45 采纳率: 100%
浏览 1677
已采纳

ssm项目springmvc中加入websocke后mybatis不能注入mapper

spring——mybatis文件

   <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
        <property name="driverClass" value="${jdbc.driverClassName}" />
        <property name="jdbcUrl" value="${jdbc.url}" />
        <property name="user" value="${jdbc.username}" />
        <property name="password" value="${jdbc.password}" />
        <property name="autoCommitOnClose" value="true"/>
        <!-- property name="checkoutTimeout" value="${cpool.checkoutTimeout}"/ -->
        <property name="initialPoolSize" value="${cpool.initialPoolSize}"/>
        <property name="minPoolSize" value="${cpool.minPoolSize}"/>
        <property name="maxPoolSize" value="${cpool.maxPoolSize}"/>
        <property name="maxIdleTime" value="${cpool.maxIdleTime}"/>
        <property name="acquireIncrement" value="${cpool.acquireIncrement}"/>
        <property name="idleConnectionTestPeriod" value="${cpool.idleConnectionTestPeriod}"/>
        <property name="acquireRetryAttempts" value="${cpool.acquireRetryAttempts}"/>
        <property name="maxStatements" value="${c3p0.maxStatements}"/>
        <property name="maxStatementsPerConnection" value="${c3p0.maxStatementsPerConnection}"/>
    </bean> 


    <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
        <property name="dataSource" ref="dataSource" />
        <!-- mapper和resultmap配置路径 --> 
        <property name="mapperLocations"> 
          <list> 
            <value>classpath:com/yuan/*/entity/*.mapper.xml</value> 
          </list> 
        </property>        
    </bean>



      <!--  设置扫描根路径也就是你的mybatis的mapper接口所在包路径;
        凡是markerInterface这个接口的子接口都参与到这个扫描,
        也就是说所有的mapper接口继承这个SqlMapper。--> 
        <bean name="SqlMapper" class="com.yuan.framework.mapper.SqlMapper"> </bean>
      <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"> 
        <property name="basePackage" value="com.yuan.*.mapper"/> 
        <property name="markerInterface" ref="SqlMapper" />
      </bean> 


        <!-- TransactionManager 事务管理 -->
         <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">  
               <property name="dataSource" ref="dataSource" />  
         </bean>  


    <!--启动spring事务注解功能-->
    <tx:annotation-driven transaction-manager="transactionManager" />

springmvc文件

  <mvc:annotation-driven/> 
  <!--   <mvc:resources location="/" mapping="/**"/>  -->
    <!-- 自动扫描controller包下的所有类,使其认为spring mvc的控制器 -->  
    <context:component-scan base-package="com.yuan.*.controller" />  

    <bean id="myHandler" class="com.yuan.framework.websocket.WebsocketEndPoint"></bean>
    <websocket:handlers>
        <websocket:mapping path="/myHandler" handler="myHandler"/>
        <websocket:handshake-interceptors>
            <bean class="com.yuan.framework.websocket.HandshakeInterceptor"/>
        </websocket:handshake-interceptors>
    </websocket:handlers>

  <!--   <websocket:handlers >
        <websocket:mapping path="/sockjs/myHandler" handler="myHandler"/>
        <websocket:sockjs/>
    </websocket:handlers> -->





    <!-- 避免IE执行AJAX时,返回JSON出现下载文件 -->
    <bean id="mappingJacksonHttpMessageConverter" class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
        <property name="supportedMediaTypes">
            <list>
                <value>text/html;charset=UTF-8</value>
            </list>
        </property>
    </bean>

    <!-- 启动Spring MVC的注解功能,完成请求和注解POJO的映射 -->
    <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
        <property name="messageConverters">
            <list>
                <ref bean="mappingJacksonHttpMessageConverter" /><!-- json转换器 -->
            </list>
        </property>
        <!-- 日期格式转换 -->
        <property name="webBindingInitializer">
         <bean class="com.yuan.framework.util.DateConverter"/>
        </property>
    </bean>

    <!-- 对模型视图名称的解析,即在模型视图名称添加前后缀 -->
    <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver" p:prefix="/" p:suffix=".jsp" />

    <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
        <property name="defaultEncoding">
            <value>UTF-8</value>
        </property>
        <property name="maxUploadSize">
            <value>32505856</value><!-- 上传文件大小限制为31M,31*1024*1024 -->
        </property>
        <property name="maxInMemorySize">
            <value>4096</value>
        </property>
    </bean>
  • 写回答

1条回答 默认 最新

  • devmiao 2016-10-15 15:21
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 MATLAB动图问题
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名