<?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:aop="http://www.springframework.org/schema/aop"
        xmlns:context="http://www.springframework.org/schema/context" 
        xmlns:jee="http://www.springframework.org/schema/jee"
        xsi:schemaLocation="
            http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
            http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
            http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
            http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
            http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd">
    <bean id="mydataSource"
            class="org.apache.commons.dbcp.BasicDataSource">
            <property name="url"
                value="jdbc:oracle:thin:@localhost:1521:orcl">
            </property>
            <property name="driverClassName" 
                value="oracle.jdbc.driver.OracleDriver">
            </property>
            <property name="username" value="scott"></property>
            <property name="password" value="920525"></property>    
        </bean>
        
        
        <bean id="sessionFactory" 
            class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
            <!-- 注入连接参数 -->
            <property name="dataSource" ref="mydataSource">
            </property>
            
            <!-- 注入hibernate配置参数 -->
            <property name="hibernateProperties">
                <props>
                    <prop key="hibernate.dialect">org.hibernate.dialect.OracleDialect</prop>
                    <prop key="hibernate.show_sql">true</prop>
                    <prop key="hibernate.fromat_sql">true</prop>
                </props>
            </property>    
            
            <!-- 设置加载的hbm.xml -->
            <property name="mappingResources">
                <list>
                    <value>com/tarena/netctoss/pojo/cost.hbm.xml</value>
                    <value>com/tarena/netctoss/pojo/account.hbm.xml</value>
                </list>
            </property>
        </bean>
        <!-- 开启组件扫描,后面的值是自己配置,看看需要扫描那些包,自己定义-->
        <context:component-scan base-package="com.tarena.netctoss"/>
    
     <!-- 声明事务管理,采用AOP形式切入 -->
        <bean id="txManager"
            class="org.springframework.orm.hibernate3.HibernateTransactionManager">
            <property name="sessionFactory" ref="sessionFactory"></property>
        </bean>
        <tx:annotation-driven proxy-target-class="true" transaction-manager="txManager"/>
</beans>

上面是application.xml文件配置

 

下面是web.xml文件中的配置

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" 
    xmlns="http://java.sun.com/xml/ns/javaee" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
    http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
        <!-- 指定要加载的Spring文件 -->
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath:applicationContext-*.xml</param-value>
    </context-param>
    
    <!-- 用于实例化Spring容器,默认加载/WEB-INF/applicationContext.xml -->
    <listener>
        <listener-class>
            org.springframework.web.context.ContextLoaderListener    
        </listener-class>
    </listener>
    
    <filter>
        <filter-name>opensessioninview</filter-name>
        <filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
        </filter-class>
    </filter>

    
    <filter>
        <filter-name>Struts2</filter-name>
        <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
    </filter>
    
    <filter-mapping>
        <filter-name>opensessioninview</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
    
    <filter-mapping>
        <filter-name>Struts2</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
<welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> </web-app>

再有struts.xml文件的话,这个里面简单,自己写就可以了(也得根据需求来写)

再将ssh的jar包都导入,基本上基本的ssh环境就搭建好了

posted on 2013-07-30 23:34  一号码农  阅读(245)  评论(0编辑  收藏  举报