applicationContext.xml的具体配置讲解
***************************ApplicationContext.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"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:jpa="http://www.springframework.org/schema/data/jpa"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa-1.0.xsd">
<context:property-placeholder location="classpath:crius.properties"></context:property-placeholder>
<context:component-scan base-package="cn.damai.boss.SOASystem" />
<!--建立数据源 -->
<bean id="reportCenter_dataSource" value="com.mysql.jdbc.Driver" />
<!--数据库地址 -->
<property name="jdbcUrl" value="jdbc:mysql://localhost:3306/test" />
<!--数据库用户名 -->
<property name="user" value="root" />
<!--数据库密码 -->
<property name="password" value="111111" />
<!--连接池初始化时获取的链接数,介于minPoolSize和maxPoolSize之间 -->
<property name="initialPoolSize" value="20" />
<!--最小连接数和最大连接数 -->
<property name="minPoolSize" value="20" />
<property name="maxPoolSize" value="50" />
<!-- 最大空闲的时间,单位是秒,无用的链接再过时后会被回收-->
<property name="maxIdleTime" value="25000" />
<!--在当前连接数耗尽的时候,一次获取的新的连接数 -->
<property name="acquireIncrement" value="2" />
<!--每60秒检查所有连接池中的空闲连接。Default: 0 -->
<property name="idleConnectionTestPeriod" value="60" />
<!--因性能消耗大请只在需要的时候使用它。如果设为true那么在每个connection提交的
时候都将校验其有效性。建议使用idleConnectionTestPeriod或automaticTestTable
等方法来提升连接测试的性能。Default: false -->
<property name="testConnectionOnCheckout" value="true" />
<!--如果设为true那么在取得连接的同时将校验连接的有效性。Default: false -->
<property name="testConnectionOnCheckin" value="true" />
<property name="checkoutTimeout" value="5000" />
<property name="preferredTestQuery">
<value>SELECT NOW() FROM DUAL</value>
</property>
</bean>
<!--配置实体管理器 -->
<bean id="reportCenter_entityManagerFactory"
ref="reportCenter_dataSource" />
<!--映射persistence.xml文件 -->
<property name="persistenceUnitName" value="reportCenter" />
<property name="persistenceXmlLocation" value="classpath*:META-INF/persistence.xml" />
<property name="jpaVendorAdapter">
<bean value="false" />
<property name="showSql" value="true" />
</bean>
</property>
</bean>
<!--事务管理器 -->
<bean id="reportCentertransactionManager" ref="reportCenter_entityManagerFactory" />
</bean>
<tx:annotation-driven transaction-manager="reportCentertransactionManager" />
<jpa:repositories base-package="cn.damai.boss.SOASystem"
query-lookup-strategy="create-if-not-found"
entity-manager-factory-ref="reportCenter_entityManagerFactory"
transaction-manager-ref="reportCentertransactionManager">
</jpa:repositories>
</beans>
************************crius.properties配置文件**************************
# --------------datasource config start--------------#
reportCenter.jdbc.driverClassName=com.mysql.jdbc.Driver
reportCenter.jdbc.url=jdbc\:mysql\://192.168.4.169\:3306/report_system?useUnicode\=true&characterEncoding\=UTF8&zeroDateTimeBehavior\=round
reportCenter.jdbc.username=root
reportCenter.jdbc.password=123456
reportCenter.jdbc.initialPoolSize=5
reportCenter.jdbc.minPoolSize=5
reportCenter.jdbc.maxPoolSize=30
reportCenter.jdbc.maxIdleTime=25000
reportCenter.jdbc.acquireIncrement=2
reportCenter.jdbc.idleConnectionTestPeriod=60
reportCenter.jdbc.testConnectionOnCheckout=true
reportCenter.jdbc.testConnectionOnCheckin=true
#reportCenter.jdbc.automaticTestTable=test_c3p0
reportCenter.jdbc.checkoutTimeout=5000
# --------------datasource config end----------------#
#oa dubbo
oadubbo.zookeeper.address=zookeeper://192.168.4.202:2181
#area dubbo
areadubbo.zookeeper.address=zookeeper://192.168.4.202:2181
#B2C
jdbc.xplat.driver=com.mysql.jdbc.Driver
jdbc.xplat.url=jdbc:mysql://192.168.4.203:3306/xplatform
jdbc.xplat.user=root
jdbc.xplat.pwd=123456
jdbc.xplat.initialSize=5
jdbc.xplat.maxActive=30
jdbc.xplat.maxIdle=5
jdbc.xplat.minIdle=5
*************************************persistence.xml****************************
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"version="2.0">
<persistence-unit name="reportCenter" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:/MySqlDS</jta-data-source>
<!-- <class>cn.damai.boss.reportCenter.service.User</class> -->
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
</properties>
</persistence-unit>
</persistence>