一、源码下载(转载并修改):

https://github.com/haoranhaoshi/eclipse-jax-ws-spring-mybatis-cxf-mysql

二、介绍:

1、com.sshome.ssmcxf.dao及sqlMapper/user.xml属于数据链路层;

2、com.sshome.ssmcxf.entity是实体(Java Bean),toString()负责转json格式;

3、config/applicationContext-webservice.xml负责数据返回的网址;

4、config/init.properties负责数据库连接配置

5、连接Oracle使用ojdbc14,init.properties:

jdbc.driverClassName=oracle.jdbc.driver.OracleDriver

jdbc.url=jdbc:oracle:thin:@localhost:1521:orcl

jdbc.username=lin

jdbc.password=lin

cpool.checkoutTimeout=5000

cpool.minPoolSize=1

cpool.maxPoolSize=100

cpool.maxIdleTime=7200

6、连接Mysql使用mysql-connector-java-5.1.10-bin,init.properties:

jdbc.driverClassName=com.mysql.jdbc.Driver

jdbc.url=jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull

jdbc.username=root

jdbc.password=root

cpool.checkoutTimeout=5000

cpool.minPoolSize=1

cpool.maxPoolSize=100

cpool.maxIdleTime=7200

7、实现登陆功能,即查询用户名密码是否存在

8、工程导入后如果工程有错误(工程名有红叉),可打开Windows-show views-Problems中查看,jre或BuildPath或class path的错误可在工程右键Build Path,在libraries中remove后重新Add,之后在project中clean,或者close project后再open project;

参考;

http://blog.csdn.net/marty_zhu/article/details/2566299

9、Referenced file contains errors (http://cxf.apache.org/schemas/jaxws.xsd)错误或者警告参考;

http://blog.csdn.net/wwhrestarting/article/details/46681489

10、可使用WebService Studio进行测试,较为方便。

三、构成

1、sqlMapper的xml:sql语句与interface和dao方法的映射。

2、serviceImpl:根据参数调用一个或多个dao方法读写数据库,需对类注解@Service,对dao方法注解@Autowired,对方法推荐注解@Override。

3、webserviceImpl:汇总所有webservice方法等待客户端调用,可进行jsonString和实体entity或实体集合List<entity>的转换,对类注解@Transactional
@Service
@WebService(endpointInterface="com.jobWanted.webservice.ScmWebService", serviceName = "ScmWebService")

4、applicationContext-webservice.xml:发布webservice地址。

5、applicationContext.xml:dao层与sqlMapper层的包级映射,与init.properties(数据库配置内容)结合配置数据库。

6、sqlmap-config.xml:数据库映射配置。

Logo

瓜分20万奖金 获得内推名额 丰厚实物奖励 易参与易上手

更多推荐