在使用过hibernate ibatis 之后,还是喜欢ibatis的那种写原生态的SQL, 便追随着ibatis来到mybatis.
由于spring3的发布在mybatis3之前,所以并没有对mybatis3提供官方支持. 于是便引出了mybatis-spring*.jar(由mybats的官方提供)
由于项目是C/S 架构的,我选用cxf将服务发不成webservice,再用spring管理mybatis的sessionfactory.
各配置如下:
在applicationContext-beans.xml中:
<bean id="baseDao" class="org.mybatis.spring.mapper.MapperFactoryBean">
<property name="sqlSessionFactory" ref="sqlSessionFactory" />
<property name="mapperInterface" value="com.socogame.base.dao.IBaseDao" />
</bean>
<bean id="gameDao" parent="baseDao">
<property name="mapperInterface" value="com.socogame.dao.IGameDao" />
</bean>
<bean id="gameLogic" class="com.socogame.logic.GameLogic">
<property name="gameDao" ref="gameDao" />
</bean>
在bean.xml中:
<bean id="gameService" class="com.socogame.service.impl.GameServiceImpl" >
<property name="gameLogic" ref="gameLogic" />
</bean>
<jaxws:endpoint id="gameServiceWs" address="/gameService" implementor="#gameService" />
代码见附件,不能传附件,见链接: http://download.csdn.net/detail/lesblueleaves/4305589
另附客户端代码,gamews为安卓代码,我是选用ksoap2包调用webservice 链接:http://download.csdn.net/detail/lesblueleaves/4305562
p.s 在下才疏学浅,恳请高手指点一二...