现在的位置: 首页 > 综合 > 正文

去掉Atomikos的日志提示信息:没有设置属性文件的路径

2013年03月31日 ⁄ 综合 ⁄ 共 1485字 ⁄ 字号 评论关闭

 

去掉Atomikos的日志提示信息:没有设置属性文件的路径

 

Setting Atomikos System Properties in Spring

The Spring Bean configuration of the class UserTransactionServiceImp described above can be used to set the Atomikos
JTA properties. However there are three JVM (or System) properties that cannot be set through the constructor of the UserTransactionServiceImp class or via any programmatic means.
These properties are:

  • com.atomikos.icatch.file
  • com.atomikos.icatch.no_file
  • com.atomikos.icatch.hide_init_file_path

Fortunately, it is possible to set the value of system properties within a Spring configuration file through the use of Spring's MethodInvokingFactoryBean class. For example:

<bean id="setMyAtomikosSystemProps"
      class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
        <property name="targetObject">
            <!-- System.getProperties() -->
            <bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
                <property name="targetClass" value="java.lang.System" />
                <property name="targetMethod" value="getProperties" />
            </bean>
        </property>
        <property name="targetMethod" value="putAll" />
        <property name="arguments">
            <!-- The new Properties -->
            <props>
                <prop key="com.atomikos.icatch.file">/etc/myapp/jta.properties</prop>
                <prop key="com.atomikos.icatch.hide_init_file_path">true</prop>
            </props>
        </property>
    </bean>

In order for this to work, the Atomikos beans must add the Spring attribute "depend-on=" and add the Id of this bean. This will ensure the system property values are set prior to the initialization of Atomikos.

 

在spring的配置文件中添加上方的代码,然后在Atomikos beans中加入 "depend-on=setMyAtomikosSystemProps",就可以了。

 

以上信息,仅供参考,希望对您有所帮助。

抱歉!评论已关闭.