applicationContext_common.xml配置模板mysql

applicationContext_common.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:aop="http://www.springframework.org/schema/aop"
       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.1.xsd
       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
       http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
       http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
       ">

	
    <context:annotation-config />
	
	<!-- 扫描com.app包及其子包 -->
    <context:component-scan base-package="com.app.*" annotation-config="true" />

	<!-- 引入hibernate和数据源数据 -->
    <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="locations">
            <list>
                <value>classpath:com/resources/resources.properties</value>
            </list>
        </property>
    </bean>

    
	<!-- 配置proxool数据源 -->
  	<bean id="dataSource" class="org.logicalcobwebs.proxool.ProxoolDataSource">
		<property name="alias" value="proxoolDataSource"/>
		<property name="driver" value="${connection.driver_class}" />
		<property name="driverUrl" value="${connection.url}" />
		<property name="user" value="${connection.username}" />
		<property name="password" value="${connection.password}" />
		<property name="maximumConnectionCount" value="${proxool.maximum.connection.count}"/>
		<property name="minimumConnectionCount" value="${proxool.minimum.connection.count}" />
		<property name="statistics" value="${proxool.statistics}" />
		<property name="simultaneousBuildThrottle" value="${proxool.simultaneous.build.throttle}"/>
	</bean>

  	<bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean" >
    	<property name="dataSource" ref="dataSource"/>
    	<property name="packagesToScan">
			<list>
				<value>com.app</value>
			</list>
		</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">true</prop>
                <prop key="javax.persistence.validation.mode">none</prop>
                <prop key="hibernate.hbm2ddl.auto">update</prop>
            </props>
        </property>
  	</bean>
  	
  
	<!-- hibernate事务管理器 -->
    <bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager">
        <property name="sessionFactory" ref="sessionFactory"/>
    </bean>

	<!-- 使用注解方式声明事务 -->
    <tx:annotation-driven transaction-manager="transactionManager" />

</beans>


resources.properties配置文件

hibernate.dialect=org.hibernate.dialect.MySQLInnoDBDialect
hibernate.hbm2ddl.auto=none
hibernate.show_sql=true



connection.driver_class=com.mysql.jdbc.Driver
connection.url=jdbc:mysql://localhost:3306/ssh
connection.username=root
connection.password=?

proxool.maximum.connection.count=40
proxool.minimum.connection.count=5
proxool.statistics=1m,15m,1h,1d
proxool.simultaneous.build.throttle=30


web.xml配置文件

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">
  <display-name>ssh</display-name>
  <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath*:com/resources/applicationContext_*.xml</param-value>
  </context-param>
  <filter>
    <filter-name>encoding</filter-name>
    <filter-class>
            org.springframework.web.filter.CharacterEncodingFilter
        </filter-class>
    <init-param>
      <param-name>encoding</param-name>
      <param-value>UTF-8</param-value>
    </init-param>
    <init-param>
      <param-name>forceEncoding</param-name>
      <param-value>true</param-value>
    </init-param>
  </filter>
  <filter>
    <filter-name>struts2</filter-name>
    <filter-class>
            org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
  </filter>
  <filter-mapping>
    <filter-name>struts2</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>
  <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>
  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>
</web-app>




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值