SSH中Spring以及hibernate、Redis的xml配置
2017-11-07 21:17
459 查看
<?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:tx="http://www.springframework.org/schema/tx" xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context" xmlns:aop="http://www.springframework.org/schema/aop" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.3.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.3.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.3.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd" default-autowire="byName" default-lazy-init="false"> <!-- 定义受环境影响易变的变量 --> <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="locations"> <list> <!-- 标准配置 --> <value>classpath:jdbc.properties</value> </list> </property> </bean> <!-- 使用annotation 自动注册bean,并保证@Required,@Autowired的属性被注入 --> <context:component-scan base-package="com.test.server" /> <context:annotation-config /> <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"> <property name="driverClass" value="
com.mysql.jdbc.Driver" /><property name="jdbcUrl" value="
jdbc:mysql:///test? useUnicode=true&characterEncoding=UTF-8& 1autoReconnect=true" /><property name="user" value="root" /> <property name="password" value="1234" /> <property name="initialPoolSize" value="10" /> <!--连接空闲时间(秒) --> <property name="maxIdleTime" value="200" /> <property name="maxPoolSize" value="50" /> <property name="minPoolSize" value="10" /> <!--获取新连接的等待时间(毫秒)0一直等待 --> <property name="checkoutTimeout" value="30000" /> <!--检测空闲连接的时间间隔(秒) --> <property name="idleConnectionTestPeriod" value="150" /> <!--<property name="testConnectionOnCheckout" value="true" />--> </bean> <!-- Hibernate配置 --> <bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"> <property name="dataSource" ref="dataSource" /> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop> <prop key="hibernate.show_sql">true</prop> <prop key="hibernate.connection.release_mode">auto</prop> <prop key="hibernate.hbm2ddl.auto">update</prop>
</props> </property>
<!-- 配置扫描bean value:配置bean包 -->
<property name="packagesToScan" value="com.test.server.data" /> </bean> <!--配置Redis--> <bean id="redisPoolConfig" class="redis.clients.jedis.JedisPoolConfig"> <property name="maxIdle" value="100"/> <property name="maxTotal" value="300" /> <property name="maxWaitMillis" value="60000" /> <property name="testOnBorrow" value="false" /> <property name="testOnReturn" value="false" /> <property name="timeBetweenEvictionRunsMillis" value="60000" /> <property name="minEvictableIdleTimeMillis" value="120000" /> <property name="numTestsPerEvictionRun" value="-1" /> </bean> <bean id="jedisConnectionFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory" p:hostName="${redis.hostName}" p:port="${redis.port}" p:password="${redis.password}" p:usePool="true" p:poolConfig-ref="redisPoolConfig"/> <bean id="redisTemplate" class="org.springframework.data.redis.core.RedisTemplate" p:connectionFactory-ref="jedisConnectionFactory"/> <!-- 事务管理器配置,单数据源事务 --> <bean id="txManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory" /> </bean> <tx:advice id="txAdvice" transaction-manager="txManager"> <tx:attributes> <tx:method name="get*" read-only="true" /> <tx:method name="find*" read-only="true" /> <tx:method name="query*" read-only="true" /> <tx:method name="is*" read-only="true" /> <tx:method name="*" propagation="REQUIRED" /> </tx:attributes> </tx:advice> <!-- 使用annotation定义事务 --> <tx:annotation-driven transaction-manager="txManager" proxy-target-class="true"/> <aop:config proxy-target-class="true"> <aop:advisor pointcut="execution(* com.test.server.service..*Manager.*(..))" advice-ref="txAdvice" /> <aop:advisor pointcut="execution(* com.test.server.dao..*Dao.*(..))" advice-ref="txAdvice" /> </aop:config></beans>
相关文章推荐
- Hibernate 注解时 hibernate.hbm.xml的配置方法 以及与SSH整合里的配置方式
- SSH开发环境的配置:web.xml、Spring集成hibernate和Spring集成Struts2
- ssh整合!Struts.xml、hibernate与spring整合的applicationContext.xml、web.xml文件的配置!
- 关于搭建restful web service + springMVC + ibatis/hibernate的整合和XML配置意思和ssh+springMVC框架搭建
- Spring整合Hibernate的XML文件配置,以及web.xml文件配置
- Proxool在web项目中的配置,以及与spring3、hibernate4的集成
- ssh中整合spring和hibernate之后的application.xml文件的超详细配置
- spring aop的使用(注解方式以及基于xml配置方式)
- jsf、Spring、Hibernate 集成 faces-managed-beans.xml 配置
- 最简单的SSH(Struts+Spring+Hibernate)[二]配置文件
- ssh整合源码一:配置Spring之applicationContext.xml和web.xml
- spring整合dwr架构(ftl+ssm)以及dwr.xml配置,原理,优缺点讲解,面试题总结
- web.xml中配置spring的几种方式 以及 Spring获取Bean的几种方式
- spring context.xmL配置数据库事务以及aop
- Spring整合Hibernate配置(使用hibernate.cfg.xml文件)
- 基于xml配置的Spring AOP切面的几点总结,以及简单的例子
- spring==注解事务问题以及xml事务的配置
- 在eclipse中关于Spring和Hibernate 的XML配置如何提示类的包路径的办法
- Spring 3.1 + JPA 2.0 (Hibernate 4) + MySQL 配置 移走persistence.xml。
- ssh整合:将hibernate的配置信息,配置到Spring的配置文件中(Spring整合hibernate)