原创作品,允许转载,转载时请务必标明作者信息和声明本文章==》http://www.cnblogs.com/zhu520/p/7774144.html  

这边文章是接的刚刚前一遍的基础上敲的 SSH框架的多表查询和增删查改 (方法一)上

 

  SSH框架的多表查询和增删查改 (方法一)中

  一:

现在配置你的 applicationContext.xml , web.xml 配置文件

1):applicationContext.xml  --》这些配置你大概大概理解就好不要敲啊,反正我是复制的这些配置

这篇文章讲解了Spring 开启Annotation <context:annotation-config> 和 <context:component-scan>诠释及区别   

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:p="http://www.springframework.org/schema/p"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
    xsi:schemaLocation="
    http://www.springframework.org/schema/tx
    http://www.springframework.org/schema/tx/spring-tx-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/context  
    http://www.springframework.org/schema/context/spring-context-3.1.xsd  
    http://www.springframework.org/schema/beans 
    http://www.springframework.org/schema/beans/spring-beans-3.1.xsd"
    default-autowire="byName">

    <!-- 开启注解 -->
    <context:annotation-config />
    <!-- spring 扫描路径,注意当前工程只需要扫描dao和service,srpingmvc或者struts2注解才有变化 -->
    <context:component-scan base-package="zhu.dao,zhu.service" />

    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
        <property name="driverClassName" value="com.mysql.jdbc.Driver">
        </property>
        <property name="url" value="jdbc:mysql://127.0.0.1:3306/jdbc01">
        </property>
        <property name="username" value="root"></property>
        <property name="password" value="root"></property>
    </bean>
    <bean id="sessionFactory"
        class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
        <property name="dataSource">
            <ref bean="dataSource" />
        </property>
        <property name="hibernateProperties">
            <props>
                <prop key="hibernate.dialect">
                    org.hibernate.dialect.MySQLDialect
                </prop>
                <prop key="hibernate.show_sql">
                    true
                </prop>
                <!-- 这个是有了之后,就算你再mysql没有表,运行也不会出错,因为有它会自动新建表,已存在不会新建 -->
                <prop key="hibernate.hbm2ddl.auto">update</prop>

            </props>
        </property>
        <property name="mappingDirectoryLocations">
            <list>
                <value>classpath:zhu/cfg/</value>
            </list>
        </property>
    </bean>
   <!-- 配置声明式事务管理(采用注解的方式) -->
    <bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
        <property name="sessionFactory" ref="sessionFactory"></property>
    </bean>
    <!-- 开启注解事务 --> <!-- 用注解来实现事务管理 -->  
    <tx:annotation-driven transaction-manager="txManager"/>
</beans>
View Code

相关文章:

  • 2021-05-15
  • 2022-12-23
  • 2021-12-17
  • 2021-09-27
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-04-01
  • 2021-11-20
  • 2022-01-01
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案