2 Star 3 Fork 3

study/schoolshop

Create your Gitee Account
Explore and code with more than 14 million developers,Free private repositories !:)
Sign up
文件
Clone or Download
applicationContext.xml 4.00 KB
Copy Edit Raw Blame History
樊长润 authored 2016-01-23 20:05 +08:00 . schoolshop
<?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:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
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
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">
<!--
项目部署路径D:\workspaces\.metadata\.plugins\org.eclipse.wst.server.core\tmp2\wtpwebapps
使用数据源和指定persistence.xml位置的方式创建entityManagerFactory,如果使用的不是hibernate
JPA实现, 需要在tomcat作一些特殊配置.具体参考手册
注意:使用该方式需要把persistence.xml中的hibernate.connection.driver_class,hibernate.connection.username,
hibernate.connection.password,hibernate.connection.url配置删除
-->
<!-- 属性编辑器 -->
<context:property-placeholder location="classpath:jdbc.properties" />
<!-- 自动扫描类上的注解 -->
<context:component-scan base-package="com.schoolcloud" />
<!-- 配置数据源 -->
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
destroy-method="close">
<property name="driverClass" value="${driverClass}" />
<property name="jdbcUrl" value="${jdbcUrl}" />
<property name="user" value="${user}" />
<property name="password" value="${password}" />
<!-- 初始化时获取的连接数,取值应在minPoolSize与maxPoolSize之间。Default: 3 -->
<property name="initialPoolSize" value="${initialPoolSize}" />
<!-- 连接池中保留的最小连接数。 -->
<property name="minPoolSize" value="${minPoolSize}" />
<!-- 连接池中保留的最大连接数。Default: 15 -->
<property name="maxPoolSize" value="${maxPoolSize}" />
<!-- 最大空闲时间,60秒内未使用则连接被丢弃。若为0则永不丢弃。Default: 0 -->
<property name="maxIdleTime" value="${maxIdleTime}" />
<!-- 当连接池中的连接耗尽的时候c3p0一次同时获取的连接数。Default: 3 -->
<property name="acquireIncrement" value="${acquireIncrement}" />
<!-- 每60秒检查所有连接池中的空闲连接。Default: 0 -->
<property name="idleConnectionTestPeriod" value="${idleConnectionTestPeriod}" />
</bean>
<!--
配置工厂,这个EntityManagerFactory由spring来去提供,作用类似于hibernate中的SessionFactory
-->
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="persistenceXmlLocation" value="classpath:META-INF/persistence.xml" />
<property name="loadTimeWeaver">
<bean class="org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver" />
</property>
</bean>
<!-- 建立视图内拦截器来解决JPA中访问延迟加载属性时产生的无会话异常 -->
<!-- LazyInitializationException: could not initialize proxy no session -->
<!-- 此拦截器会注入到servlet配置中的DefaultAnnotationHandlerMapping中 -->
<!-- <bean name="openEntityManagerInViewInterceptor" class="org.springframework.orm.jpa.support.OpenEntityManagerInViewInterceptor">
<property name="entityManagerFactory">
<ref bean="entityManagerFactory" />
</property>
</bean> -->
<!-- 配置JPA事务管理器 -->
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>
<tx:annotation-driven transaction-manager="transactionManager" />
</beans>
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Java
1
https://gitee.com/MyJavaCode/schoolshop.git
git@gitee.com:MyJavaCode/schoolshop.git
MyJavaCode
schoolshop
schoolshop
master

Search