Spring Applicationcontext.xml and Hibernate.cfg.xml settings

Source: Internet
Author: User

Applicationcontext.xml Configuration

<?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:aop= "HTTP://WWW.SPRINGFRAMEWORK.ORG/SCHEMA/AOP"  xmlns:tx= "http ://www.springframework.org/schema/tx "       xsi:schemalocation="/http www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd  http://www.springframework.org/schema/context http://www.springframework.org/schema/context/ spring-context.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/ Aop/spring-aop.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx /spring-tx.xsd ">    <context:property-placeholder location= "Classpath:database.properties" ></context: property-placeholder>    <!--     Read resource files using JavaBean      <bean id= "Placeholderconfigurer"  class= " Org.springframework.beans.factory.config.PropertyPlaceholderConfigurer ">         <property name= "Location" >             <value>classpath:system.properties</value>         </property>        <property name= " fileencoding " value=" UTF-8 "/>    </bean>-->         <!--  Specify ioc  automatically scanned package  -->    <context:component-scan  base-package= "Com.lingdong" ></context:component-scan>  &nbsP; <bean id= "Messagesource"  class= " Org.springframework.context.support.ResourceBundleMessageSource ">         <property name= "basename"  value= "Messages"/>         <property name= "defaultencoding"  value= "UTF-8"/>         <property name= "Usecodeasdefaultmessage"  value= "true"/>     </bean>    <!--  Configure Data source  -->    <bean id= " DataSource " class=" Com.mchange.v2.c3p0.ComboPooledDataSource ">         <property name= "Driverclass" >             <value>${jdbc.driverClass}</value>         </property>        <property Name= "Jdbcurl" >            <value>${ jdbc.url}</value>        </property>         <property name= "User" >             <value>${jdbc.userName}</value>         </property>        <property name= "Password" >            <value>${jdbc.password}</ value>        </property>         <property name= "Initialpoolsize" >             <value>${jdbc.initialPoolSize}</value>         </property>&nBsp;       <property name= "Maxpoolsize" >             <value>${jdbc.maxPoolSize}</value>         </property>    </bean>     <!--  Configuration  hibernate  sessionfactory -->    <bean id= "Sessionfactory"  class= "Org.springframework.orm.hibernate4.LocalSessionFactoryBean" >         <property name= "DataSource"  ref= "DataSource" ></property>         <property name= "Configlocation" >             <value>${hibernate.cfg.xml}</value>         </property>         <property name= "MAppinglocations ">            <value>${ hibernate.hbm.xml}</value>        </property>     </bean>    <!--<bean id= "Loggingaspect"  class= " Com.lingdong.aop.LoggingAspect "/>-->    <!--spring aop  Enable automatic proxy annotations  -- >    <!--<aop:aspectj-autoproxy proxy-target-class= "true"/>-->     <!--configuration aop  pointcuts,-->    <!--<aop:config>         <aop:pointcut id= "pointcut"  expression= "Execution (*  Com.lingdong.aop.*.* (..)) " ></aop:pointcut>        <aop:aspect ref= " Loggingaspect ">            <aop:before  Method= "Before"  pointcut-ref= "Pointcut" &GT;&LT;/AOP:BEFORE&GT;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&LT;/AOP: aspect>    </aop:config>-->    <!--  Configuration  spring   Declarative Transactions  -->    <!--  Configure transaction manager  -->    < Bean id= "TransactionManager"  class= "Org.springframework.orm.hibernate4.HibernateTransactionManager" >        <property name= "SessionFactory"  ref= " Sessionfactory "></property>    </bean>    <!--enable transaction annotations   Driver, use annotations to configure transactions using-->    <!--<tx:annotation-driven transaction-manager= " TransactionManager "></tx:annotation-driven>-->    <!--  Configure transaction Properties  -- >    <tx:advice id= "Txadvice"  transaction-manager= "TransactionManager" >         <tx:attributes>             <tx:method name= "add*"  propagation= "REQUIRED"/>             <tx:method name= "select*"  read-only= "true"/>             <tx:method name= "update*"  propagation = "REQUIRED"/>            <tx:method  Name= "delete*"  propagation= "REQUIRED"/>             <tx:method name= "*"/>        </tx:attributes >    </tx:advice>    <!--  Configuring transaction pointcuts, associating with transaction properties    --&GT;&NBSP;&NBSP;&NBSP;&NBSP;&LT;AOP:CONFIG&GT;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&LT;AOP: Pointcut expression= "Execution (* com.lingdong.service.*.* (..)) "  id= "Pointcut" ></aop:pointcut>        <aop:advisor  advice-ref= "Txadvice"  pointcut-ref= "Pointcut" ></aop:advisor>    </ Aop:config></beans>

Hibernate.cfg.xml Configuration

<?xml version= ' 1.0 '  encoding= ' utf-8 '? ><! doctype hibernate-configuration public         "-//Hibernate/ hibernate configuration dtd//en "        "/http Www.hibernate.org/dtd/hibernate-configuration-3.0.dtd ">


This article is from the Java Technology Blog blog, so be sure to keep this source http://lingdong.blog.51cto.com/3572216/1889446

Spring Applicationcontext.xml and Hibernate.cfg.xml settings

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.