ssh 搭建框架spring相关配置(1)

来源:互联网 发布:java web课程设计 编辑:程序博客网 时间:2024/05/17 07:54

初学ssh,不知道从何下手,都是头们配置好了我们接着做,先把配置好的备份一份,供大家一起学习。

<?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:context="
http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"
 xsi:schemaLocation="
  
http://www.springframework.org/schema/beansfile:///e:/resource/dtd/spring/spring-beans-2.5.xsd
  http://www.springframework.org/schema/aopfile:///e:/resource/dtd/spring/spring-aop-2.5.xsd
  http://www.springframework.org/schema/contextfile:///e:/resource/dtd/spring/spring-context-3.0.xsd
  http://www.springframework.org/schema/txfile:///e:/resource/dtd/spring/spring-tx-2.5.xsd">

 <!-- 配置dataSource -->
 <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
  <property name="driverClass" value="oracle.jdbc.driver.OracleDriver" />
  <property name="jdbcUrl" value="jdbc:oracle:thin:@localhost:1521:dmas" />
  <property name="user" value="dmas" />
  <property name="password" value="dmas" />

  <!-- 初始化时获取的连接数  -->
  <property name="initialPoolSize" value="20" />
  <!-- 连接池中保留的最小连接数。 -->
  <property name="minPoolSize" value="15" />
  <!-- 连接池中保留的最大连接数。  -->
  <property name="maxPoolSize" value="300" />
  <!-- 最大空闲时间,60秒内未使用则连接被丢弃。 -->
  <property name="maxIdleTime" value="60" />
  <!-- 当连接池中的连接耗尽的时候c3p0一次同时获取的连接数。  -->
  <property name="acquireIncrement" value="5" />
  <!-- 每60秒检查所有连接池中的空闲连接。  -->
  <property name="idleConnectionTestPeriod" value="60" />
 </bean>

 <!-- 配置sessionFactory -->
 <bean id="sessionFactory"
  class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
  <property name="dataSource" ref="dataSource" />
  <property name="mappingResources">


   <list>
    <!-- 权限设置 -->
    <value>com/kaixiang/dmas/model/Authority.hbm.xml</value>
    <value>com/kaixiang/dmas/model/Department.hbm.xml</value>
    <value>com/kaixiang/dmas/model/User.hbm.xml</value>
    <value>com/kaixiang/dmas/model/Position.hbm.xml</value>
    <value>com/kaixiang/dmas/model/Role.hbm.xml</value>
   </list>


  </property>
  <property name="hibernateProperties">
   <props>
    <prop key="hibernate.dialect">
     org.hibernate.dialect.OracleDialect
    </prop>
    <prop key="hibernate.hbm2ddl.auto">update</prop>
   </props>
  </property>
 </bean>

 <!-- 配置事务 -->
 <bean id="transactionManager"
  class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
  <property name="dataSource" ref="dataSource" />
 </bean>

 <tx:advice id="txadvice" transaction-manager="transactionManager">
  <tx:attributes>
   <tx:method name="get*" read-only="true" propagation="NOT_SUPPORTED" />
   <tx:method name="find*" read-only="true" propagation="NOT_SUPPORTED" />
   <tx:method name="*" />
  </tx:attributes>
 </tx:advice>
 <aop:config>
  <aop:pointcut id="transactionPointcut"
   expression="execution(* com.kaixiang.dmas.service..*.*(..)) || execution(* com.kaixiang.dmas.security..*.*(..))" />
  <aop:advisor advice-ref="txadvice" pointcut-ref="transactionPointcut" />
 </aop:config>

 <!-- 以下为梁发文负责部分 -->

 <!-- 通用DAO -->
 <bean name="commonDao" class="com.kaixiang.dmas.dao.impl.CommonDaoImpl">
  <property name="sessionFactory" ref="sessionFactory" />
 </bean>

 <!-- 工程进度 -->
 <bean name="projectProgressDao" class="com.kaixiang.dmas.dao.impl.ProjectProgressDaoImpl">
 </bean>
 <bean name="projectProgressService"
  class="com.kaixiang.dmas.service.impl.ProjectProgressServiceImpl">
  <property name="projectProgressDao" ref="projectProgressDao" />
  <property name="commonDao" ref="commonDao" />
 </bean>
 <bean name="projectProgressAction" class="com.kaixiang.dmas.action.ProjectProgressAction"
  scope="prototype">
  <property name="projectProgressService" ref="projectProgressService" />
 </bean>

 <!-- END  -->

</beans>