github.com/emc-advanced-dev/unik@v0.0.0-20190717152701-a58d3e8e33b7/docs/examples/example_osv_java_servlet/src/main/resources/spring/business-config.xml (about) 1 <?xml version="1.0" encoding="UTF-8"?> 2 <!-- 3 Repository and Service layers 4 --> 5 <beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" 6 xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx" 7 xmlns:jpa="http://www.springframework.org/schema/data/jpa" xmlns="http://www.springframework.org/schema/beans" 8 xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd 9 http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd 10 http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd 11 http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"> 12 13 <!-- ========================= RESOURCE DEFINITIONS ========================= --> 14 15 <!-- import the dataSource definition --> 16 <import resource="datasource-config.xml"/> 17 18 <context:component-scan 19 base-package="org.springframework.samples.petclinic.service"/> 20 21 <!-- Configurer that replaces ${...} placeholders with values from a properties file --> 22 <!-- (in this case, JDBC-related settings for the JPA EntityManager definition below) --> 23 <context:property-placeholder location="classpath:spring/data-access.properties" system-properties-mode="OVERRIDE"/> 24 25 <!-- enables scanning for @Transactional annotations --> 26 <tx:annotation-driven/> 27 28 29 <!-- ================== 3 Profiles to choose from =================== 30 - jdbc (uses Spring" JdbcTemplate) 31 - jpa 32 - spring-data-jpa 33 =============================================================================--> 34 35 <beans profile="jpa,spring-data-jpa"> 36 <!-- JPA EntityManagerFactory --> 37 <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean" 38 p:dataSource-ref="dataSource"> 39 <property name="jpaVendorAdapter"> 40 <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter" 41 p:database="${jpa.database}" p:showSql="${jpa.showSql}"/> 42 <!-- the 'database' parameter refers to the database dialect being used. 43 By default, Hibernate will use a 'HSQL' dialect because 'jpa.database' has been set to 'HSQL' 44 inside file spring/data-access.properties 45 46 --> 47 </property> 48 <!-- gDickens: BOTH Persistence Unit and Packages to Scan are NOT compatible, persistenceUnit will win --> 49 <property name="persistenceUnitName" value="petclinic"/> 50 <property name="packagesToScan" value="org.springframework.samples.petclinic"/> 51 </bean> 52 53 <!-- Transaction manager for a single JPA EntityManagerFactory (alternative to JTA) --> 54 <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager" 55 p:entityManagerFactory-ref="entityManagerFactory"/> 56 57 58 <!-- 59 Post-processor to perform exception translation on @Repository classes (from native 60 exceptions such as JPA PersistenceExceptions to Spring's DataAccessException hierarchy). 61 --> 62 <bean class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor"/> 63 64 </beans> 65 66 <beans profile="jdbc"> 67 <!-- Transaction manager for a single JDBC DataSource (alternative to JTA) --> 68 <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager" 69 p:dataSource-ref="dataSource"/> 70 71 <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate"> 72 <constructor-arg ref="dataSource"/> 73 </bean> 74 75 <bean id="namedParameterJdbcTemplate" 76 class="org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate"> 77 <constructor-arg ref="dataSource"/> 78 </bean> 79 80 <context:component-scan base-package="org.springframework.samples.petclinic.repository.jdbc"/> 81 </beans> 82 83 <beans profile="jpa"> 84 <!-- 85 Loads JPA beans 86 Will automatically be transactional due to @Transactional. 87 EntityManager will be auto-injected due to @PersistenceContext. 88 PersistenceExceptions will be auto-translated due to @Repository. 89 --> 90 <context:component-scan base-package="org.springframework.samples.petclinic.repository.jpa"/> 91 </beans> 92 93 <beans profile="spring-data-jpa"> 94 <jpa:repositories base-package="org.springframework.samples.petclinic.repository.springdatajpa"/> 95 </beans> 96 </beans>