为了账号安全,请及时绑定邮箱和手机立即绑定

问下一下spring和mybatis整合问题

问下一下spring和mybatis整合问题

漫之旅 2017-09-22 17:32:46
 <?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans                      http://www.springframework.org/schema/beans/spring-beans.xsd                     http://www.springframework.org/schema/context                      http://www.springframework.org/schema/context/spring-context.xsd                     http://www.springframework.org/schema/tx                      http://www.springframework.org/schema/tx/spring-tx.xsd                      http://www.springframework.org/schema/aop                      http://www.springframework.org/schema/aop/spring-aop.xsd"> <!-- 给FACTORY 提供数据源的配置 --> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">  <property name="driverClassName" value="com.mysql.jdbc.Driver"></property>  <property name="url" value="jdbc:mysql://localhost:3306/newsystem"></property>  <property name="username" value="root"></property>  <property name="password" value="123456"></property>   </bean>  <!-- 将MYBATIS的SqlSessionFactory 交给SPRING IOC容器管理,factory的生命周期受容器的控制 --> <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">  <property name="dataSource" ref="dataSource"></property>  <!-- <property name="configLocation" value="classpath:MyBatis-Configuration.xml"></property>-->  </bean> <!-- 配置dao --> <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">  <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"></property>  <property name="basePackage" value="com.news.mapper"></property> </bean> <!-- servlet --> <bean id="gc" class="yewu.Gongchang">   </bean>  <!-- Service --> <bean id="commentsService" class="service.CommentsService"> </bean> <bean id="newsService" class="service.NewsService"> <property name="mapper" ref=""/>////////////////////////这里的ref怎么填啊,我是用属性注入,不是注解注入啊 </bean> <bean id="newsUsersService" class="service.NewsUsersService"> </bean> <bean id="topicService" class="service.TopicService"> </bean>  <!-- action --> <bean id="indexJsp" class="jsp.indexJsp">  <property name="newsService" ref="newsService">  </property>  <property name="topicService" ref="topicService"></property> </bean></beans>
查看完整描述

1 回答

已采纳
?
HansonQ

TA贡献223条经验 获得超56个赞

不要用ref引用,试试用value然后里面写mapper全限定名称试试。

查看完整回答
反对 回复 2017-09-23
  • 漫之旅
    漫之旅
    mapper全限定名只的是什么?包名?还是mapper类名,还是mapperXML名
  • HansonQ
    HansonQ
    包名加类名
  • 漫之旅
    漫之旅
    说错了,那个是接口,没有实现类
点击展开后面1
  • 1 回答
  • 0 关注
  • 885 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信