gpt4 book ai didi

intellij-idea - 如何将当前年份插入 IntelliJ IDEA 版权模板?

转载 作者:行者123 更新时间:2023-12-04 02:50:01 29 4
gpt4 key购买 nike

我正在尝试在 IntelliJ IDEA 版权设置中为 MIT 许可证制作 Apache Velocity 模板。我希望它打印 2015-${current_year}年份在哪里。这是我尝试在设置→版权→版权配置文件→麻省理工学院→版权文本中输入的内容:

#set ($current_year = $dateTool.getCurrentDate('yyyy'))
Copyright (c) 2015-${current_year}, My Name

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

但是,当我使用此模板在源文件中生成许可证头时,它不会打印当前年份编号,它只打印纯文本 ${current_year} .

如何让它打印当前年份?

最佳答案

This page of the documentation解释设置→版权所有→版权配置文件的内置速度变量:

Name    Type        Comment
$today DateInfo The current date and time.
...
DateInfo has the following properties:
year int The current year.

所以就我而言,我需要在我的模板中使用它:
Copyright (c)  2015-${today.year}, My Name

关于intellij-idea - 如何将当前年份插入 IntelliJ IDEA 版权模板?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30618147/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com