Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/335.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 在Spring配置中使用时间戳_Java_Spring_Java 8 - Fatal编程技术网

Java 在Spring配置中使用时间戳

Java 在Spring配置中使用时间戳,java,spring,java-8,Java,Spring,Java 8,在Spring配置中,我们可以在启动服务时将时间戳或uuid作为动态值吗 <bean id="atomikosUserTransactionService" class="com.atomikos.icatch.config.UserTransactionServiceImp" init-method="init" destroy-method="shutdownForce"> <constructor-arg>

在Spring配置中,我们可以在启动服务时将时间戳或uuid作为动态值吗

<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>

{timestamp}/log/
{timestamp}/log/
我想在每次运行应用程序时都将文件夹目录与时间戳放在一起

我正在使用Spring4.15,目前无法升级


问候。

对于简单的约会,请尝试使用SpEL
对于简单的日期,请尝试使用SpEL,而不是
{timestamp}
->
{new java.util.Date().toString()}


下面的类不是
{timestamp}
->
{new java.util.Date().toString()}

而是有一个返回当前时间戳的方法,它将被执行以获取当前时间戳

public class CurrTime {

    public long getCurrTimestamp() {
        return System.currentTimeMillis();
    }

}
xml
文件中创建上述类的bean

<bean id="currTime" class="path.to.CurrTime"></bean>

下面的类有一个返回当前时间戳的方法,它将被执行以获取当前时间戳

public class CurrTime {

    public long getCurrTimestamp() {
        return System.currentTimeMillis();
    }

}
xml
文件中创建上述类的bean

<bean id="currTime" class="path.to.CurrTime"></bean>

你试过了吗?也是在春季4.15?我记得它从3版一直支持到现在你试过了吗?它也是在4.15春季?关于。我记得它从3版到现在都支持,这很好知道,但是答案{new java.util.Date().toString()}不需要任何实现是的,
{new java.util.Date().toString()}
很容易使用,但是如果需要任何修改,那么一个方法会更好。很好知道,但是答案是肯定的#{new java.util.Date().toString()}不需要任何实现是的,
{new java.util.Date().toString()}
很容易使用,但是,如果需要任何修改,那么使用一种方法会更好。