Skip to content

Instantly share code, notes, and snippets.

@michail-nikolaev
Created September 9, 2012 22:38
Show Gist options
  • Save michail-nikolaev/3687745 to your computer and use it in GitHub Desktop.
Save michail-nikolaev/3687745 to your computer and use it in GitHub Desktop.
Spring - JPA using profiles
<?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:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.1.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.1.xsd"
xmlns:util="http://www.springframework.org/schema/util">
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="emf"/>
</bean>
<tx:annotation-driven/>
<beans profile="dev">
<bean id="emf" class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean">
<property name="persistenceUnitName" value="devUnit"/>
</bean>
</beans>
<beans profile="prod">
<bean id="emf" class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean">
<property name="persistenceUnitName" value="productionUnit"/>
</bean>
</beans>
<beans profile="test">
<bean id="emf" class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean">
<property name="persistenceUnitName" value="testUnit"/>
</bean>
</beans>
/beans>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment