spring2.5+ibatis3+web service cxf 例子MyEclipse工程



 spring2.5+ibatis3+web service cxf 例子MyEclipse工程

本工程仅供学习用.

 

 

 

 

 

1: web.xml 配置

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.5"
	xsi:schemaLocation="http://java.sun.com/xml/ns/javaee   http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">


	<!-- Spring ApplicationContext配置文件的路径?,可使用通配符,多个路径用?1,号分隔
		此参数用于后面的Spring-Context loader -->
	<context-param>
		<param-name>contextConfigLocation</param-name>
		<param-value>classpath*:config/spring/*.xml</param-value>
	</context-param>

	<listener>
		<listener-class>
			org.springframework.web.context.ContextLoaderListener
		</listener-class>
	</listener>

     
      <listener>  
          <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>  
      </listener>  
        
      <!-- xcf configuration -->  
      <servlet>  
          <servlet-name>CXFServlet</servlet-name>  
          <servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>  
      </servlet>  
     <servlet-mapping>  
         <servlet-name>CXFServlet</servlet-name>  
         <url-pattern>/*</url-pattern>  
      </servlet-mapping>  

	<welcome-file-list>
		<welcome-file>index.jsp</welcome-file>
		<welcome-file>index.html</welcome-file>
	</welcome-file-list>


	<!-- Error Page定义 -->
	<error-page>
		<error-code>500</error-code>
		<location>/commons/error.jsp</location>
	</error-page>

	<!-- Error Page定义 -->
	<error-page>
		<error-code>500</error-code>
		<location>/error.jsp?id=500</location>
	</error-page>
	<error-page>
		<error-code>404</error-code>
		<location>/error.jsp?id=404</location>
	</error-page>
	<error-page>
		<error-code>403</error-code>
		<location>/error.jsp?id=403</location>
	</error-page>

	<!-- 著名 Character Encoding filter -->
	<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>

	<!--Spring ApplicationContext 载入 -->
	<listener>
		<listener-class>
			org.springframework.web.context.ContextLoaderListener
		</listener-class>
	</listener>

	<!-- 使Spring支持request与session的scope,如:<bean id="loginAction" class="com.foo.LoginAction" scope="request"/> -->
	<listener>
		<listener-class>
			org.springframework.web.context.request.RequestContextListener
		</listener-class>
	</listener>

	<!-- Spring 刷新Introspector防止内存泄露 -->
	<listener>
		<listener-class>
			org.springframework.web.util.IntrospectorCleanupListener
		</listener-class>
	</listener>

</web-app>

 

 

2:spring 几个配置文件:

ibatis3 配置 applicationContext-ibatis3-dao.xml

 

<?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:context="http://www.springframework.org/schema/context"
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"
    default-autowire="byName" default-lazy-init="false">

	<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
        <property name="dataSource" ref="dataSource"/>
    </bean>
    
    <!-- Transaction manager for a single JDBC DataSource -->
    <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
        <property name="dataSource" ref="dataSource"/>
    </bean>

    <bean id="sqlSessionFactory" class="com.mylink.javacommon.SqlSessionFactoryFactoryBean">
        <property name="configLocation" value="classpath:config/properties/configuration.xml"/>
        <property name="mapperLocations" value="classpath*:/com/**/dao/**/**/*Mapper.xml"/>
        <property name="dataSource" ref="dataSource"/>
    </bean>

    <!-- component-scan自动搜索@Component , @Controller , @Service , @Repository等标注的类 -->
	<context:component-scan base-package="com.**.dao.*"/>
	
    
</beans>

 

bean 配置 applicationContext-service.xml

 

<?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:context="http://www.springframework.org/schema/context"
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"
	default-autowire="byName" default-lazy-init="false">

	<!-- component-scan自动搜索@Component , @Controller , @Service , @Repository等标注的类 -->
	<!-- 默认值如果适合,该项可以不用修改 -->
	<context:component-scan base-package="com.*.smartanswer.service.*.impl" />
	

	<!-- 获取spring上下文 -->
	<bean id="SpringContextUtil" class="com.mylink.javacommon.util.SpringContextUtil" />
 
	 
</beans>

 

 

其它的就不多说了.见附件.

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值