zoukankan      html  css  js  c++  java
  • spring配置和映射文件

    配置

    <?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" default-autowire="byType">
    <!-- 配置数据源-连接池 -->
    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
    <property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"></property>
    <property name="url" value="jdbc:oracle:thin:195.168.1.195:1521/orcl"></property>
    <property name="username" value="t_demo"></property>
    <property name="password" value="123456"></property>
    <property name="maxActive" value="10"></property>
    <property name="maxIdle" value="8"></property>
    <property name="minIdle" value="5"></property>
    </bean>

    <!-- 配置SessionFactory -->
    <bean name="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
    <!-- 引入数据源 -->
    <property name="dataSource" ref="dataSource"></property>
    <!-- 引入映射文件 -->
    <property name="packagesToScan">
    <!-- 相当于<mapping class="全限定名" /> -->
    <list>
    <!-- 给出实体类所在范围 -->
    <value>com.oak.entity</value>
    </list>
    </property>

    <!-- 配置参数 -->
    <property name="hibernateProperties">
    <!-- 集合注入 -->
    <props>
    <prop key="hibernate.dialect">org.hibernate.dialect.OracleDialect</prop>
    <prop key="hibernate.show_sql">true</prop>
    <!-- 自动建表key值固定的 -->
    <prop key="hibernate.hbm2ddl.auto">update</prop>
    </props>
    </property>
    </bean>

    <!-- 扫描注解 -->
    <context:component-scan base-package="com"></context:component-scan>
    <!-- 日志打印 -->
    <aop:aspectj-autoproxy></aop:aspectj-autoproxy>

    </beans>

    映射文件

    <?xml version="1.0" encoding="utf-8"?>
    <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

    <!-- hibernate-mapping标签中有个package属性,表示持久化类所在的包 package="com.oak.pojo"
    如果此处加了package属性,则class标签的属性name值只写类名即可,
    如果hibernate-mapping标签中没加package属性
    则class标签的name值为 全限定名(表名+类名)-->
    <hibernate-mapping>
    <!-- 对应类和表 -->
    <class name="com.oak.entity.Goods" table="T_GOODS">
    <!-- 对应的属性和字段 -->
    <id name="id" column="id">
    <generator class="native"></generator>
    </id>
    <!-- 给非主属性和非主字段 -->
    <property name="goodsname" column="goodsname"></property>
    <property name="weight" column="weight"></property>
    <property name="price" column="price"></property>
    <property name="color" column="color"></property>
    <property name="shangtime" column="shangtime" type="java.sql.Date"></property>
    <property name="stock" column="stock"></property>

    <many-to-one name="brand" class="com.oak.entity.Brand">
    <column name="BRANDID"></column>
    </many-to-one>

    <many-to-one name="smc" class="com.oak.entity.SmallClass">
    <column name="SID"></column>
    </many-to-one>
    </class>
    </hibernate-mapping>

  • 相关阅读:
    link标签中的integrity和crossorigin字段
    jquery中的插件EChars的使用
    php函数 截断字符
    子元素脱离文档标准流,父元素没有高度解决办法
    有序无序Ul->Li Ol->Li菜单,默认点击当前弹出下拉,再次点击收起下拉菜单(变形2 ---修饰)
    有序无序ul->li ol->li菜单,默认点击当前弹出下拉,再次点击收起下拉菜单
    bootstrap使用总结(carousel设置大小。item设置大小,img设置大小)
    bootstrap使用总结(导航在carousel居中之上)
    html中设置height=100%无效的问题
    第四次上机课
  • 原文地址:https://www.cnblogs.com/love1/p/7976810.html
Copyright © 2011-2022 走看看