问下一下spring和mybatis整合问题

 

<?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>

漫之旅
浏览 881回答 1
1回答

HansonQ

不要用ref引用,试试用value然后里面写mapper全限定名称试试。
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java