봄과 최대 절전 모드를 사용하는 웹 응용 프로그램에서 최대 절전 모드 구성은 META-INF/persistence.xml
이지만 한 가지 문제가 있습니다. 우리는 두 개의 다른 데이터베이스를 사용하고 있습니다. 하나는 테스트 용이고 다른 하나는 프로덕션 용입니다.봄과 최대 절전 모드 - 방언 변경
여기 런타임시 hibernate.properties
의 값을 변경하거나 예 JNDI
자원이 값을 저장하는 것이 가능하다
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
version="2.0">
<persistence-unit name="SpringMVCTest" transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:/comp/env/jdbc/sqliteDS</jta-data-source>
<class>pl.meble.taboret.model.UserEntity</class>
<class>pl.meble.taboret.model.WordList</class>
<class>pl.meble.taboret.model.WordUnit</class>
<class>pl.meble.taboret.model.ActivateUserAccountPermaLink</class>
<class>pl.meble.taboret.model.ResetPasswordPermaLink</class>
<class>pl.meble.taboret.question.QuestionUnit</class>
<class>pl.meble.taboret.question.OpenQuestion</class>
<class>pl.meble.taboret.question.MultipleChoiceQuestion</class>
<class>pl.meble.taboret.question.WithGapsQuestion</class>
<class>pl.meble.taboret.question.QuestionList</class>
<class>pl.meble.taboret.answer.AnswerUnit</class>
<class>pl.meble.taboret.answer.OpenQuestionAnswer</class>
<class>pl.meble.taboret.answer.MultipleChoiceQuestionAnswer</class>
<class>pl.meble.taboret.answer.WithGapsQuestionAnswer</class>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="hibernate.dialect" value="pl.meble.taboret.utils.SQLiteDialect" />
<property name="hibernate.hbm2ddl.auto" value="update" />
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.format_sql" value="true" />
<property name="hibernate.use_sql_comments" value="true" />
<!-- <property name="hibernate.connection.driver_class" value="${database.driver}"
/> <property name="hibernate.connection.url" value="${database.url}" /> -->
<!-- <property name="hibernate.transaction.factory_class" value="org.hibernate.transaction.JTATransactionFactory"/> -->
<!--<property name="hibernate.transaction.factory_class" value="com.atomikos.icatch.jta.hibernate3.AtomikosJTATransactionFactory"/> -->
<property name="hibernate.transaction.manager_lookup_class" value="com.atomikos.icatch.jta.hibernate3.TransactionManagerLookup"/>
</properties>
</persistence-unit>
</persistence>
그래서 우리의 persistence.xml '인가요?
hibernate.dialect
을 조건부로 설정하는 다른 방법이 있습니다. 예를 들어 테스트를 위해 SQLite 방언을 사용하고 일반 배포의 경우 Postgre 방언을 사용합니다.
을로드하여이 문제를 해결할 수 있습니다 (여기를 클릭하십시오.) (http : //stackoverflow.com/questions/33166150/hibernate-jta-read-db-connection-parameters-per-environment/33309337#33309337) –