我有一个用maven编译的WAR档案。 我想在jsf页面中插入编译时间戳。
如何在编译时更改jsf页面中的字符串? 实施例
with recursive cte(id, run_hour, performance_hour, value) as
(
select *
from
(
select distinct on (id)
id,
run_hour,
greatest(performance_hour, timestamp '2017-06-25 07:00') as performance_hour,
value
from metrics
where run_hour = timestamp '2017-06-25 09:00'
and performance_hour <= timestamp '2017-06-25 07:00'
order by id, metrics.performance_hour desc
) start_by_id
union all
select
cte.id,
cte.run_hour,
cte.performance_hour + interval '1 hour' as performance_hour,
coalesce(m.value, cte.value) as value
from cte
left join metrics m on m.id = cte.id
and m.run_hour = cte.run_hour
and m.performance_hour = cte.performance_hour + interval '1 hour'
where cte.performance_hour < timestamp '2017-06-25 09:00'
)
select id, sum(value)
from cte
group by id;
必须成为
<div>Compiled at (copilationTime)</div>
如果它太复杂了,我有一个applicationcooped bean,我写了
<div>Compiled at 2017-01-01 15:50</div>
但在我的课堂上,如何设置&#39; xxxx&#39;?
<div>Compiled at ${MyApp.compilationTime}</div>
答案 0 :(得分:1)
我认为您正在讨论通过maven-resources-plugin
进行资源过滤的各种变体。这个想法是这样的:
src/main/resources
资源或其变体,通过maven-resources-plugin
,src/main/webapp
资源maven-war-plugin
)过滤你已经放置了Maven预定义变量$ {maven.build.timestamp} Class.getResourceAsStream
(或其变体)或servlet机制(取决于您放置它的位置)读取该资源。请注意,你可以让Maven直接在JSF中替换一个变量过滤器,并采取一些步骤。
答案 1 :(得分:0)
从this answer您可以获得对文件的引用:
final File classFile = new File(MyApp.class.getProtectionDomain().getCodeSource().getLocation().getPath());
然后从here获得财产:
BasicFileAttributes attr = Files.readAttributes(classFile, BasicFileAttributes.class);
String compilationTime = attr.creationTime().toString();
答案 2 :(得分:0)
您可以使用@CompileTime from Kolobok并创建一个字段
@CompileTime
private static long ct; // This field will contain compilation time in ms