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个回答

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐