0
我已經配置bitronix連接oracle數據庫如下:配置bitronix事務管理上的春天開機
<bean id="bitronixTMConfig" factory-method="getConfiguration" class="bitronix.tm.TransactionManagerServices">
<!-- Disabling Jmx avoids registering JMX Beans to any container -->
<!-- <property name="disableJmx" value="true" /> -->
<property name="serverId" value="request-handler-node" />
<property name="defaultTransactionTimeout" value="300" />
<!-- <property name="logPart1Filename" value="C:\temp\bit-btm1.tlog" /> -->
<!-- <property name="logPart2Filename" value="C:\temp\bit-btm2.tlog" /> -->
</bean>
<bean id="bitronixTM" factory-method="getTransactionManager" class="bitronix.tm.TransactionManagerServices" depends-on="bitronixTMConfig" />
<bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager" primary="true">
<property name="transactionManager" ref="bitronixTM" />
<property name="userTransaction" ref="bitronixTM" />
<property name="allowCustomIsolationLevels" value="true" />
</bean>
<bean id="applicationDataSource" class="bitronix.tm.resource.jdbc.PoolingDataSource" init-method="init" destroy-method="close">
<property name="uniqueName" value="applicationDataSource" />
<property name="className" value="oracle.jdbc.xa.client.OracleXADataSource" />
<property name="minPoolSize" value="${requestHandlerNode.repository.app.minPoolSize}" />
<property name="maxPoolSize" value="${requestHandlerNode.repository.app.maxPoolSize}" />
<property name="testQuery" value="SELECT 1 FROM DUAL" />
<property name="allowLocalTransactions" value="true" />
<property name="driverProperties">
<props>
<prop key="user">${requestHandlerNode.repository.app.username}</prop>
<prop key="password">${requestHandlerNode.repository.app.password}</prop>
<prop key="URL">${requestHandlerNode.repository.app.url}</prop>
</props>
</property>
</bean>
和POM依賴關係:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-batch</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-rest</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jms</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jta-bitronix</artifactId>
</dependency>
<dependency>
<groupId>javax.jms</groupId>
<artifactId>jms-api</artifactId>
</dependency>
<dependency>
<groupId>javax.transaction</groupId>
<artifactId>javax.transaction-api</artifactId>
</dependency>
<dependency>
<groupId>org.codehaus.btm</groupId>
<artifactId>btm</artifactId>
<exclusions>
<exclusion>
<groupId>javax.transaction</groupId>
<artifactId>jta</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc6</artifactId>
<version>11.2.0</version>
</dependency>
<dependency>
<groupId>weblogic</groupId>
<artifactId>wlthint3client</artifactId>
<version>12.2.1</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
但在啓動時我收到此錯誤:
Caused by: java.lang.IllegalStateException: cannot change the configuration while the transaction manager is running
at bitronix.tm.Configuration.checkNotStarted(Configuration.java:699) ~[btm-2.1.4.jar:2.1.4]
at bitronix.tm.Configuration.setLogPart1Filename(Configuration.java:166) ~[btm-2.1.4.jar:2.1.4]
at org.springframework.boot.autoconfigure.transaction.jta.BitronixJtaConfiguration.bitronixConfiguration(BitronixJtaConfiguration.java:69) ~[spring-boot-autoconfigure-1.3.7.RELEASE.jar:1.3.7.RELEASE]
at org.springframework.boot.autoconfigure.transaction.jta.BitronixJtaConfiguration$$EnhancerBySpringCGLIB$$a487082a.CGLIB$bitronixConfiguration$1(<generated>) ~[spring-boot-autoconfigure-1.3.7.RELEASE.jar:1.3.7.RELEASE]
at org.springframework.boot.autoconfigure.transaction.jta.BitronixJtaConfiguration$$EnhancerBySpringCGLIB$$a487082a$$FastClassBySpringCGLIB$$c66fa53d.invoke(<generated>) ~[spring-boot-autoconfigure-1.3.7.RELEASE.jar:1.3.7.RELEASE]
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228) ~[spring-core-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:355) ~[spring-context-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.boot.autoconfigure.transaction.jta.BitronixJtaConfiguration$$EnhancerBySpringCGLIB$$a487082a.bitronixConfiguration(<generated>) ~[spring-boot-autoconfigure-1.3.7.RELEASE.jar:1.3.7.RELEASE]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_77]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_77]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_77]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_77]
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
... 19 common frames omitted
我想這個例外是由於春季啓動和我的應用程序這兩個事實初始化bitronix transactionManager。
如何正確配置帶彈簧引導的Bitronix?
感謝您的幫助。
那麼不要...... Spring Boot已經爲您做了所有這些工作,而不是針對它的框架。 –
好的,謝謝,但我怎麼能配置數據源屬性,用戶名,密碼,url,classname和其他屬性,連接Oracle數據庫? –
您正在使用Spring Boot等技術,您是否花時間閱讀手冊?只需配置正確的'spring.datasource。*'屬性,如'username','password'和'url'。 –