SSH环境搭建(hibernate5.2.1,spring 4.2)

来源:互联网 发布:mysql 子查询不走索引 编辑:程序博客网 时间:2024/06/06 05:26

app-base.xml

<?xml version="1.0" encoding="UTF-8"?><beans  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"        xmlns:p="http://www.springframework.org/schema/p"        xmlns="http://www.springframework.org/schema/beans"        xmlns:aop="http://www.springframework.org/schema/aop"        xmlns:context="http://www.springframework.org/schema/context"        xmlns:mvc="http://www.springframework.org/schema/mvc"        xmlns:tx="http://www.springframework.org/schema/tx"        xsi:schemaLocation="http://www.springframework.org/schema/beans                            http://www.springframework.org/schema/beans/spring-beans-4.2.xsd                            http://www.springframework.org/schema/aop                            http://www.springframework.org/schema/aop/spring-aop-4.1.xsd                            http://www.springframework.org/schema/context                            http://www.springframework.org/schema/context/spring-context-4.2.xsd                            http://www.springframework.org/schema/tx                            http://www.springframework.org/schema/tx/spring-tx-4.1.xsd                            http://www.springframework.org/schema/mvc                               http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsd">      <bean id="data" class="org.apache.commons.dbcp2.BasicDataSource">        <!-- 驱动 -->        <property name="driverClassName" value="com.mysql.jdbc.Driver"></property>        <!-- url -->        <property name="url" value="jdbc:mysql://localhost:3306/bbs?characterEncoding=utf-8"></property>        <!-- 用户名 -->        <property name="username" value="root"></property>        <!-- 密码 -->        <property name="password" value="99233"></property>        <!-- 最大连接数 -->        <property name="maxTotal" value="100"></property>        <!-- 最小连接数 -->        <property name="maxIdle" value="20"></property>        <!-- 超时时间 -->        <property name="maxWaitMillis" value="2000"></property>    </bean>    <!-- 会话工厂 -->    <bean id="sessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">        <!-- 设置数据源 -->        <property name="dataSource" ref="data"></property>        <!-- 设置hibernate相关配置 -->        <property name="hibernateProperties">            <props>                <!-- 方言 -->                <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>                <!-- 操作是否显示sql语句 -->                <prop key="hibernate.show_sql">true</prop>            </props>        </property>        <!-- 自动扫描指定包中的实体类 -->        <property name="packagesToScan">            <list>                <value>com.lovo.bean</value>            </list>        </property>    </bean>    <!-- 事务管理器 -->    <bean id="trans" class="org.springframework.orm.hibernate5.HibernateTransactionManager">        <property name="sessionFactory" ref="sessionFactory"></property>    </bean>    <!-- 允许使用注解配置事务 -->    <tx:annotation-driven transaction-manager="trans"/>    <!-- 扫描指定包及子包中的spring组件类 -->    <context:component-scan base-package="com.lovo.service"></context:component-scan></beans>

app_mvc.xml

0 0