项目结构:
1、ssm框架基础jar 包
[html] view plain copy aopalliance.jar aspectjrt.jar aspectjweaver.jar commons-beanutils-1.9.2.jar commons-codec-1.9.jar commons-collections-3.2.1.jar commons-dbcp-1.4.jar commons-fileupload-1.3.1.jar commons-io-2.4.jar commons-lang-2.6.jar commons-logging-1.2.jar commons-net-3.1.jar commons-pool-1.6.jar commons-pool2-2.2.jar druid-1.0.9.jar fastjson-1.1.39.jar freemarker-2.3.19.jar hamcrest-core-1.3.jar jackson-all-1.9.5.jar jboss-logging-3.1.0.CR2.jar jettison-1.0.1.jar jstl-1.1.2.jar junit-4.11.jar log4j-1.2.17.jar log4j-over-slf4j-1.7.7.jar mybatis-3.2.6.jar mybatis-spring-1.2.2.jar mysql-connector-java-5.1.30-bin.jar servlet-api.jar slf4j-api-1.7.7.jar slf4j-ext-1.7.7.jar spring-aop-4.0.2.RELEASE.jar spring-aspects-4.0.2.RELEASE.jar spring-beans-4.0.2.RELEASE.jar spring-context-4.0.2.RELEASE.jar spring-context-support-4.0.2.RELEASE.jar spring-core-4.0.2.RELEASE.jar spring-expression-4.0.2.RELEASE.jar spring-jdbc-4.0.2.RELEASE.jar spring-oxm-4.0.2.RELEASE.jar spring-test-4.0.2.RELEASE.jar spring-tx-4.0.2.RELEASE.jar spring-web-4.0.4.RELEASE.jar spring-webmvc-4.0.2.RELEASE.jar standard-1.1.2.jar 2.Apache CXF2.7 关联jar文件
[html] view plain copy cxf-2.7.3.jar httpasyncclient-4.0-beta3.jar httpclient-4.2.1.jar httpcore-4.2.2.jar httpcore-nio-4.2.2.jar neethi-3.0.2.jar wsdl4j-1.6.2.jar xmlschema-core-2.0.3.jar 3、SpringMVC的配置文件在网上存在很多资源,这里不做解释,直接上传我的web.xml 文件
[html] view plain copy <?xml version="1.0" encoding="UTF-8"?> <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <display-name></display-name> <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:spring/spring-context.xml</param-value> </context-param> <filter> <filter-name>encodingFilter</filter-name> <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class> <init-param> <param-name>encoding</param-name> <param-value>UTF-8</param-value> </init-param> <init-param> <param-name>forceEncoding</param-name> <param-value>true</param-value> </init-param> </filter> <filter-mapping> <filter-name>encodingFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <servlet> <servlet-name>springMVC</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:spring-mvc.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>springMVC</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> <!--配置apche cxf Servlet --> <!-- 配置cxf的核心控制器 --> <servlet> <servlet-name>CXFServlet</servlet-name> <servlet-class> org.apache.cxf.transport.servlet.CXFServlet </servlet-class> <load-on-startup>2</load-on-startup> </servlet> <!-- 所有来自/webservice/*的请求交给cxf处理 --> <servlet-mapping> <servlet-name>CXFServlet</servlet-name> <url-pattern>/webservice/*</url-pattern> </servlet-mapping> </web-app> 4、spring-context.xml 配置文件
[html] view plain copy <?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:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd"> <!-- 引入配置文件 --> <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="locations"> <list> <value>classpath:jdbc.properties</value> <value>classpath:memcached.properties</value> </list> </property> </bean> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName" value="${driver}" /> <property name="url" value="${url}" /> <property name="username" value="${username}" /> <property name="password" value="${password}" /> <!-- 初始化连接大小 --> <property name="initialSize" value="${initialSize}"></property> <!-- 连接池最大数量 --> <property name="maxActive" value="${maxActive}"></property> <!-- 连接池最大空闲 --> <property name="maxIdle" value="${maxIdle}"></property> <!-- 连接池最小空闲 --> <property name="minIdle" value="${minIdle}"></property> <!-- 获取连接最大等待时间 --> <property name="maxWait" value="${maxWait}"></property> </bean> <!-- spring和MyBatis完美整合,不需要mybatis的配置映射文件 --> <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> <property name="dataSource" ref="dataSource" /> <!-- 自动扫描mapping.xml文件 --> <property name="mapperLocations" value="classpath:com/wlsq/oauth/mapper/*.xml"></property> </bean> <!-- DAO接口所在包名,Spring会自动查找其下的类 --> <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"> <property name="basePackage" value="com.wlsq.oauth.dao" /> <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"></property> </bean> <!-- (事务管理)transaction manager, use JtaTransactionManager for global tx --> <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource" ref="dataSource" /> </bean> <!-- 通知 --> <tx:advice id="tx" transaction-manager="transactionManager"> <tx:attributes> <tx:method name="delete*" propagation="REQUIRED" /> <tx:method name="insert*" propagation="REQUIRED" /> <tx:method name="update*" propagation="REQUIRED" /> <tx:method name="find*" read-only="true" /> <tx:method name="get*" read-only="true" /> <tx:method name="select*" read-only="true" /> </tx:attributes> </tx:advice> <aop:config> <aop:pointcut id="pc" expression="execution(* com.common.service.*.*(..))" /> <!--把事务控制在Service层--> <aop:advisor pointcut-ref="pc" advice-ref="tx" /> </aop:config> <!--spring 集成缓存服务器(memcached) --> <bean id="memcachedPool" class="com.danga.MemCached.SockIOPool" factory-method="getInstance" init-method="initialize" destroy-method="shutDown"> <constructor-arg> <value>memCachedPool</value> </constructor-arg> <property name="servers"> <list> <value>${memcache.server}</value> </list> </property> <property name="initConn"> <value>${memcache.initConn}</value> </property> <property name="minConn"> <value>${memcache.minConn}</value> </property> <property name="maxConn"> <value>${memcache.maxConn}</value> </property> <property name="maintSleep"> <value>${memcache.maintSleep}</value> </property> <property name="nagle"> <value>${memcache.nagle}</value> </property> <property name="socketTO"> <value>${memcache.socketTO}</value> </property> </bean> <bean id="memCachedClient" class="com.danga.MemCached.MemCachedClient"> <constructor-arg> <value>memCachedPool</value> </constructor-arg> </bean> <!--ssm 集成 mongodb --> <import resource="classpath:spring/spring-mongodb.xml"/> <!--ssm 集成quartz(定时任务框架) --> <import resource="classpath:spring/spring-quartz.xml"/> <!--ssm 集成 apache cxf(webservice) --> <import resource="classpath:spring/apache-cxf.xml"/> </beans> 5、apache-cxf .xml 配置文件
[html] view plain copy <?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:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context" xmlns:jaxws="http://cxf.apache.org/jaxws" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd"> <!--CXF配置 --> <import resource="classpath:META-INF/cxf/cxf.xml" /> <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" /> <import resource="classpath:META-INF/cxf/cxf-servlet.xml" /> <!--服务端发布的webservice 在spring中使用jaxws:endpoint元素来暴露Web Service id:指在spring配置的bean的ID Implementor:指明具体的实现类 Address:指明这个web service的相对地址 --> <jaxws:endpoint id="helloWorld" implementor="com.wlsq.oauth.webservice.impl.HelloWorldImpl" address="/HelloWorld" /> </beans> 6、webservice 接口开发和接口实现类
[html] view plain copy package com.wlsq.oauth.webservice; import javax.jws.WebMethod; import javax.jws.WebParam; import javax.jws.WebService; @WebService public interface HelloWorld { @WebMethod String sayHello(@WebParam(name="username") String username); } [html] view plain copy package com.wlsq.oauth.webservice.impl; import javax.jws.WebService; import com.wlsq.oauth.webservice.HelloWorld; @WebService(endpointInterface="com.wlsq.oauth.webservice.HelloWorld",serviceName="helloWorld",targetNamespace="http://dao.cxf.ws.com/") public class HelloWorldImpl implements HelloWorld{ public String sayHello(String username) { System.out.println("sayHello() is called"); return username +" helloWorld"; } } 分享该项目资源下载路径: http://download.csdn.net/download/zhouzhiwengang/9526511
