日期:2014-05-16  浏览次数:20603 次

Axis2整合Spring连接Jdbc数据源发布
依赖spring.jar、commons-dbcp-1.4.jar、commons-pool-1.5.6.jar、
cglib-nodep-2.2.jar

jdbc.properties代码:
jdbc.driverClassName=oracle.jdbc.driver.OracleDriver
jdbc.url=jdbc:oracle:thin:@192.168.1.10:1521:oraid
jdbc.username=shihuan
jdbc.password=zznode


web.xml代码:
<?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">
	
	<context-param>
		<param-name>contextConfigLocation</param-name>
		<param-value>/WEB-INF/applicationContext.xml</param-value>
	</context-param>
	<listener>
		<listener-class>
			org.springframework.web.context.ContextLoaderListener
		</listener-class>
	</listener>
	
	
	<servlet> 
        <servlet-name>AxisServlet</servlet-name> 
        <servlet-class>org.apache.axis2.transport.http.AxisServlet</servlet-class> 
        <load-on-startup>1</load-on-startup> 
	</servlet> 
	<servlet-mapping> 
	        <servlet-name>AxisServlet</servlet-name> 
	        <url-pattern>/services/*</url-pattern> 
	</servlet-mapping>
	
	
  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>
</web-app>


applicationContext.xml代码:
<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
	   xmlns:context="http://www.springframework.org/schema/context"
	   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	   xsi:schemaLocation="http://www.springframework.org/schema/beans 
	   						http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
	   						http://www.springframework.org/schema/context 
	   						http://www.springframework.org/schema/context/spring-context-2.5.xsd">
	   
	     
	<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
  		<property name="locations">
  			<list>
  				<value>classpath:jdbc.properties</value>
  			</list>
  		</property>
 	</bean>   
	
	<!-- <context:property-placeholder location="classpath:jdbc.properties" /> -->
	<!-- <util:properties id="jdbcProperties" location="classpath:jdbc.properties"/> -->
	<!-- <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"></bean> --> 
	<!-- <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"></bean> -->
	<!-- <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"></bean> -->
	<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
		
		<property name="driverClassName" value="${jdbc.driverClassName}" />
		<property name="url" value="${jdbc.url}" />
		<property name="username" value="${jdbc.username}" />
		<property name="password" value="${jdbc.password}" />
		<!-- 
	   	<property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" />
		<property name="url" value="jdbc:oracle:thin:@192.168.1.10:1521:oraid" />
		<property name="username" value="shihuan" />
		<property name="password" value="zznode" />
		-->
		<property name="initialSize" value="10" />
		<property name="maxActive" value="100" />
		<property name="maxIdle" value="50" />
		<property name="minIdle" value="5" />
	</bean>
	
	
    <bean id="applicationContext" class="org.apache.axis2.extensions.spring.receivers.ApplicationContextHolder" />

    <bean id="springAwareService"