javaspringjava-8

Use timestamp in Spring configuration


In Spring configuration can we have a timestamp or uuid to be dynamic value when we start the service?

<bean id="atomikosUserTransactionService" class="com.atomikos.icatch.config.UserTransactionServiceImp"
          init-method="init" destroy-method="shutdownForce">
        <constructor-arg>
            <props>
                <prop key="com.atomikos.icatch.output_dir">{timestamp}/log/</prop>
                <prop key="com.atomikos.icatch.log_base_dir">{timestamp}/log/</prop>
                <!--<prop key="com.atomikos.icatch.max_actives">1000</prop>-->
            </props>
        </constructor-arg>
    </bean>

I would like to put the folder directory with timestamp every time we run the application.

I´m using Spring 4.15 and I cannot upgrade for now.

Regards.


Solution

  • For simple date try to use SpEL instead of {timestamp} -> #{new java.util.Date().toString()}