Advertisement
Javi

Ejemplo ApplicationContext: Spring + Hibernate en escritorio

Dec 22nd, 2012
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
XML 2.31 KB | None | 0 0
  1. <?xml version="1.0" encoding="UTF-8"?>
  2.  
  3. <beans xmlns="http://www.springframework.org/schema/beans"
  4.        xmlns:p="http://www.springframework.org/schema/p"
  5.       xmlns:context="http://www.springframework.org/schema/context"
  6.       xmlns:util="http://www.springframework.org/schema/util"
  7.       xmlns:tx="http://www.springframework.org/schema/tx"
  8.       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  9.       xsi:schemaLocation="
  10.           http://www.springframework.org/schema/beans
  11.           http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
  12.           http://www.springframework.org/schema/context
  13.           http://www.springframework.org/schema/context/spring-context-3.0.xsd
  14.           http://www.springframework.org/schema/util
  15.           http://www.springframework.org/schema/util/spring-util-3.0.xsd
  16.           http://www.springframework.org/schema/tx
  17.           http://www.springframework.org/schema/tx/spring-tx.xsd
  18.           ">
  19.        
  20.                            
  21.                    
  22.     <context:spring-configured />
  23.    
  24.     <context:annotation-config />
  25.     <context:component-scan base-package="xxx"/>
  26.  
  27.     <tx:annotation-driven
  28.         transaction-manager="transactionManager"/>
  29.  
  30.     <context:property-placeholder
  31.         location="classpath:META-INF/database.derby.properties"/>  
  32.     <!--
  33.     Contenido de ejemplo:
  34.         dataSource.driverClassName=org.apache.derby.jdbc.EmbeddedDriver
  35.         dataSource.url=jdbc:derby:memory:;create=true
  36.         dataSource.username=App
  37.         dataSource.password=App
  38.     -->
  39.  
  40.    
  41.     <bean id="dataSource"
  42.         class="org.springframework.jdbc.datasource.DriverManagerDataSource"
  43.         p:driverClassName="${dataSource.driverClassName}"
  44.         p:url="${dataSource.url}"
  45.         p:username="${dataSource.username}"
  46.         p:password="${dataSource.password}"
  47.     />
  48.  
  49.  
  50.     <bean id="entityManagerFactory"
  51.          class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
  52.           p:dataSource-ref="dataSource"
  53.          p:persistenceUnitName="data">
  54.         <property name="jpaVendorAdapter">
  55.             <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter" />
  56.         </property>
  57.     </bean>
  58.    
  59.      
  60.     <bean id="transactionManager"
  61.           class="org.springframework.orm.jpa.JpaTransactionManager"
  62.           p:entityManagerFactory-ref="entityManagerFactory"
  63.     />
  64.  
  65.  
  66.    
  67. </beans>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement