欢迎来到天天文库
浏览记录
ID:10076103
大小:203.50 KB
页数:17页
时间:2018-05-24
《基于axis2+mybatis的webservice》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、新建工程Flower(用MyBatis连接数据库)1.准备工作:将所用到的.jar包(包括mysql-connector-java-5.1.13-bin.jar,mybatis-3.0.4.jar,mybatis-3.0.4-sources.jar)打包成用户自定义库,在Flower中引用。将下载的axis2-1.5.4-war.zip包解压,取出axis2.war包拷贝到apache-tomcat-6.0.26webapps中,登录http://localhost:8080/axis2,点击Administr
2、ation,输入帐号admin,密码axis2可进入,点击 UploadService,将打包的.aar文件上传。文件布局如下图所示:2.service端设计(1).编写MyBatis的配置(src/Configuration.xml):
3、td">4、code=true&characterEncoding=UTF-8"/>5、e/student/mapper/StudentMapper.xml"/>(2).编写服务类的父类(src/service/BaseMybatisDao.java):packageservice;importjava.io.Reader;importorg.apache.ibatis.io.Resources;importorg.apache.ibatis.session.SqlSessionFactory;importorg.apache.ibatis.ses
4、code=true&characterEncoding=UTF-8"/>5、e/student/mapper/StudentMapper.xml"/>
5、e/student/mapper/StudentMapper.xml"/>
6、sion.SqlSessionFactoryBuilder;publicclassBaseMybatisDao{protectedstaticSqlSessionFactorysessionFactory;static{try{Readerreader=Resources.getResourceAsReader("Configuration.xml");sessionFactory=newSqlSessionFactoryBuilder().build(reader);}catch(Exceptione){e.p
7、rintStackTrace();}}}(3).编写服务端代码(src/service/student/StudentService.java):packageservice.student;importjava.text.SimpleDateFormat;importjava.util.Iterator;importjava.util.List;importorg.apache.axiom.om.OMAbstractFactory;importorg.apache.axiom.om.OMElement;impo
8、rtorg.apache.axiom.om.OMFactory;importorg.apache.axiom.om.OMNamespace;importorg.apache.ibatis.session.SqlSession;importservice.BaseMybatisDao;importservice.student.bean.StudentBean;public
此文档下载收益归作者所有