Spring&hibernate集成配置 ---- 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:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx"
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/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"
default-lazy-init="true">
<description>Spring公共配置 </description>
<!-- 定义受环境影响易变的变量 -->
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE" />
<property name="ignoreResourceNotFound" value="true" />
<property name="locations">
<list>
<!-- 标准配置 -->
<value>classpath*:/application.properties</value>
<!-- 集群中节点配置 -->
<value>classpath*:/application.cluster.properties</value>
<!-- 本地开发环境配置 -->
<value>classpath*:/application.local.properties</value>
<!-- 服务器生产环境配置 -->
<value>file:/var/springside/application.server.properties</value>
</list>
</property>
</bean>
<!-- 使用annotation 自动注册bean,并保证@Required,@Autowired的属性被注入 -->
<context:component-scan base-package="org.springside.examples.miniweb" />
<!-- 数据源配置,使用应用内的DBCP数据库连接池 -->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<!-- Connection Info -->
<property name="driverClassName" value="${jdbc.driver}" />
<property name="url" value="${jdbc.url}" />
<property name="username" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
<!-- Connection Pooling Info -->
<property name="initialSize" value="${dbcp.initialSize}" />
<property name="maxActive" value="${dbcp.maxActive}" />
<property name="maxIdle" value="${dbcp.maxIdle}" />
<property name="defaultAutoCommit" value="false" />
</bean>
<bean id="dataSource2" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="driverClass" value="${jdbc.driver}"></property>
<property name="jdbcUrl" value="${jdbc.url}"></property>
<property name="user" value="${jdbc.username}"></property>
<property name="password" value="${jdbc.password}"></property>
<property name="minPoolSize" value="1"></property>
<property name="maxPoolSize" value="20"></property>
<property name="maxIdleTime" value="1800"></property>
<property name="acquireIncrement" value="2"></property>
<property name="maxStatements" value="0"></property>
<property name="initialPoolSize" value="2"></property>
<property name="idleConnectionTestPeriod" value="1800"></property>
<property name="acquireRetryAttempts" value="30"></property>
<property name="breakAfterAcquireFailure" value="true"></property>
<property name="testConnectionOnCheckout" value="false"></property>
</bean>
<!-- 数据源配置,使用应用服务器的数据库连接池 -->
<!--<jee:jndi-lookup id="dataSource" jndi-name="java:comp/env/jdbc/ExampleDB" />-->
<!-- Hibernate配置 -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="namingStrategy">
<bean class="org.hibernate.cfg.ImprovedNamingStrategy" />
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">${hibernate.dialect}</prop>
<prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
<prop key="hibernate.format_sql">${hibernate.format_sql}</prop>
<prop key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</prop>
<prop key="hibernate.cache.provider_configuration_file_resource_path">ehcache/ehcache-hibernate-local.xml</prop>
</props>
</property>
<property name="packagesToScan" value="org.springside.examples.miniweb.entity.account" />
</bean>
<!-- 事务管理器配置,单数据源事务 -->
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<!-- 使用annotation定义事务 -->
<tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true" />
</beans>
分享到:
相关推荐
1. **自动配置**:借鉴了Spring Boot的自动配置思想,SpringSide-core-4.1.0允许开发者通过简单的配置就能启动一个完整的应用环境。 2. **安全框架集成**:集成了Spring Security,提供了用户认证、授权等功能,...
pom.xml配置 <springside.version>4.2.2.GA</springside.version> <groupId>org.springside <artifactId>springside-core ${springside.version} <classifier>tests <scope>test 手动安装至本地maven...
3. **配置管理**:通过提供统一的配置管理,Springside使得配置文件的组织和管理更加规范,降低了因配置问题导致的错误。 4. **依赖注入**:作为Spring框架的扩展,Springside充分利用了Spring的依赖注入特性,使得...
springside-core-4.3.0.jar 最新版springside-core的jar包
SpringSide 4.2.3-GA作为其稳定版本,集成了许多最新的技术和最佳实践,如Spring 4.x,Hibernate 4.x,Guava,SLF4J等,确保了项目的现代化和高效性。 在springside4-4.2.3.GA中,我们可以看到以下主要模块: 1. *...
SpringSide将Spring的配置简化,使开发者能够更快速地搭建项目。 2. **Spring MVC**:作为Spring框架的一部分,Spring MVC是一个用于构建Web应用程序的模型-视图-控制器(MVC)框架。它提供了强大的数据绑定、模型...
springside-core-4.2.2.GA.pom springside-core-4.2.2.GA.pomspringside-core-4.2.2.GA.pomspringside-core-4.2.2.GA.pomspringside-core-4.2.2.GA.pom
springside-core-4.2.3-GA.jar,如果jar包不完整,可能会导致异常:LifecycleProcessor not initialized - call 'refresh' before invoking lifecycle methods via the context
1. **示例代码**:SpringSide提供了丰富的示例代码,涵盖了Spring MVC、Spring AOP、Spring JDBC、MyBatis、Hibernate等常见模块,帮助开发者理解如何在实际项目中运用这些技术。 2. **配置文件**:包括Spring的XML...
备份自己用,太难找了,springside-core.4.0.0.RC3 。
SpringSide是基于Spring框架的一个轻量级的开发工具集,它旨在简化Spring应用的开发过程,提供了一系列实用的工具类和配置模版,使得开发者可以更加高效地进行Java企业级应用的开发。本文将对"Springside-core-4.2.2...
该项目的核心是通过集成Spring、Struts2和Hibernate等流行技术,帮助开发者快速构建高效、可维护的Java应用。"springside-springside4-1dff3fc.zip"这个压缩包包含了SpringSide 4的源码和相关文档,为开发者提供了一...
springside-core-4.2.2.GA.jar
1. **模块化设计**:SpringSide3-core的核心模块采用了模块化的结构,包括了Spring MVC、Hibernate、Quartz等常见框架的集成,使得开发者可以按需选择,避免了过度依赖,提升了项目的可维护性和灵活性。 2. **配置...
"Springside Core"是SpringSide项目的基石,它集成了大量的最佳实践和常用工具,旨在简化Spring应用的初始化和配置工作。4.1.0.GA版本是该项目的一个稳定发布,包含了对SpringSide核心功能的优化和改进,确保了代码...
springside-core-4.2.2.GA.jar 包,需要的可以自行下载,
2. **Spring集成**:作为基于Spring的工具包,springside3-core-3.0.4深度整合了Spring框架,包括依赖注入(DI)、面向切面编程(AOP)、事务管理等核心特性。通过源码分析,我们可以了解如何在实际项目中高效地利用...
可用的jar包,springside-core-4.1.1-SNAPSHOT.jar 免费下载