srping applicationContext.xml 配置

前端之家收集整理的这篇文章主要介绍了srping applicationContext.xml 配置前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
把两个xml文件放入src中

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-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/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd
					http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd"
	default-lazy-init="true">

	<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    	<property name="location">
    		<value>classpath:jdbc.properties</value>
    		<!--
			<value>/WEB-INF/jdbc.properties</value>
			-->
		</property>
	</bean>	
	<bean id="dataSource" class="org.logicalcobwebs.proxool.ProxoolDataSource">		
		<property name="driver" value="${db.driver}"/>
		<property name="driverUrl" value="${db.url}"/>
		<property name="user" value="${db.user}"/>
		<property name="password" value="${db.password}"/>
    	<property name="alias" value="${db.alias}"/>
    	<property name="houseKeepingTestsql" value="${db.houseKeepingTestsql}"/>
    	<property name="maximumConnectionCount" value="${db.maximumConnectionCount}"/>
    	<property name="minimumConnectionCount" value="${db.minimumConnectionCount}"/>
	</bean>

	<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionfactorybean">   
        <!-- 引用数据源 -->
        <property name="dataSource">
            <ref bean="dataSource" />
        </property>                 
        <property name="annotatedClasses">   
            <list>   
                <value>com.zinc.entity.ChinaCity</value>
                <value>com.zinc.entity.ExchangeVolume</value>
                <value>com.zinc.entity.FreindsInfo</value>
                <value>com.zinc.entity.Users</value>
                <value>com.zinc.entity.UserInfo</value>
                <value>com.zinc.entity.ResearchOption</value>
                <value>com.zinc.entity.ResearchTitle</value>
                <value>com.zinc.entity.Support</value>
                <value>com.zinc.entity.TopicsUsers</value>
                <value>com.zinc.entity.Topics</value>
                <value>com.zinc.entity.UserResearchOption</value>
                <value>com.zinc.entity.Video</value>
                <value>com.zinc.entity.VideoType</value>
                <value>com.zinc.entity.VideoUsers</value>
                <value>com.zinc.entity.DetermineVote</value>
                <value>com.zinc.entity.Wordcensor</value>
            	<value>com.zinc.entity.Survey</value>
            </list>   
        </property> 
        <property name="hibernateProperties">   
            <props>   
                <prop key="hibernate.dialect">org.hibernate.dialect.MysqLDialect</prop>   
                <prop key="connection.useUnicode">true</prop>
                <prop key="connection.characterEncoding">UTF-8</prop>
                <prop key="hibernate.show_sql">false</prop>   
                <prop key="hibernate.format_sql">false</prop>            
                <prop key="hibernate.jdbc.fetch_size">20</prop> 
                <prop key="hibernate.query.substitutions">true 1,false 0</prop> 
                <prop key="hibernate.jdbc.batch_size">20</prop>  
                <prop key="hibernate.cache.use_structured_entries">true</prop>
                <prop key="hibernate.cache.use_second_level_cache">true</prop> 
                <prop key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</prop>
                <prop key="hibernate.cache.provider_configuration_file_resource_path"></prop>                                    
            </props>   
         </property>               
    </bean>   
	
	<!-- 事务配置 -->
	<bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
		<property name="sessionFactory" ref="sessionFactory" />
	</bean>

	<!-- 使用annotation 自动注册bean,并检查@required,@Autowired的属性已被注入 -->
	<context:annotation-config/> 
	<context:component-scan base-package="com.zinc" />
	
	<!-- 使用annotation定义事务 -->
	<tx:annotation-driven transaction-manager="txManager" />
	</beans>


jdbc.properties
db.driver=com.MysqL.jdbc.Driver
db.url=jdbc:MysqL://localhost:3306/zinc?useUnicode=true&characterEncoding=utf-8
db.user=root
db.password=root
db.alias=MysqLPool
db.houseKeepingTestsql=select 1
db.characterEncoding=utf-8
db.maximumConnectionCount=30
db.minimumConnectionCount=5
原文链接:https://www.f2er.com/xml/293688.html

猜你在找的XML相关文章