简单的员工管理项目,使用spring、struts1、hibernate开发
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:context="http://www.springframework.org/schema/context"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
           http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
           http://www.springframework.org/schema/context
           http://www.springframework.org/schema/context/spring-context-3.0.xsd
           http://www.springframework.org/schema/tx
           http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
            http://www.springframework.org/schema/cache
            http://www.springframework.org/schema/cache/spring-cache.xsd
           http://www.springframework.org/schema/tx/spring-tx.xsd">

    <!-- 加载db.properties文件 -->
    <bean id="config" class="org.springframework.beans.factory.config.PreferencesPlaceholderConfigurer">
        <property name="locations" value="classpath*:*.properties"/>
    </bean>

    <!-- 配置配置数据库信息(替代mybatis的配置文件conf.xml) -->
    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
        <property name="driverClassName" value="${driver}"></property>
        <property name="url" value="${url}"></property>
        <property name="username" value="${username}"></property>
        <property name="password" value="${password}"></property>
        <property name="initialSize" value="${initialSize}"></property>
        <property name="maxActive" value="${maxActive}"></property>
        <property name="maxIdle" value="${maxIdle}"></property>
        <property name="minIdle" value="${minIdle}"></property>
    </bean>

    <bean id="sessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
        <property name="dataSource" ref="dataSource"></property>
        <!-- //加载实体类的映射文件位置及名称 -->
        <property name="mappingLocations" value="classpath:k/bean/*.hbm.xml"></property>
        <property name="configLocation" value="classpath:hibernate.cfg.xml"></property>
    </bean>

    <!--事务-->
    <bean id="transactionManager" class="org.springframework.orm.hibernate5.HibernateTransactionManager">
        <property name="sessionFactory" ref="sessionFactory"/>
    </bean>
    <tx:annotation-driven transaction-manager="transactionManager"/>

    <!--开启注解配置-->
    <context:annotation-config/>

    <!--配置 action-->
    <bean name="/login" class="k.action.LoginAction" scope="prototype"/>
    <bean name="/employee" class="k.action.EmployeeAction" scope="prototype"/>

    <!--配置 Service-->
    <bean name="testService" class="k.service.TestService"/>
    <bean id="employeeService" name="employeeService" class="k.service.impl.EmployeeServiceImpl"/>
    <bean name="departmentService" class="k.service.impl.DepartmentServiceImpl"/>

</beans>
View Code

相关文章:

  • 2021-05-30
  • 2021-07-30
  • 2022-12-23
  • 2021-06-03
  • 2022-01-06
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-02-22
  • 2021-07-03
  • 2022-02-10
  • 2022-12-23
  • 2022-01-16
相关资源
相似解决方案