当前位置: 代码迷 >> 综合 >> How to configure Copyright Profiles in IntelliJ IDEA
  详细解决方案

How to configure Copyright Profiles in IntelliJ IDEA

热度:9   发布时间:2023-12-15 00:36:05.0

??下面这段代码是Oracle Java SDK 1.8中java.lang.String文件的头部的Copyright信息:

/** Copyright (c) 1994, 2013, Oracle and/or its affiliates. All rights reserved.* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.** This code is free software; you can redistribute it and/or modify it* under the terms of the GNU General Public License version 2 only, as* published by the Free Software Foundation.  Oracle designates this* particular file as subject to the "Classpath" exception as provided* by Oracle in the LICENSE file that accompanied this code.** This code is distributed in the hope that it will be useful, but WITHOUT* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or* FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License* version 2 for more details (a copy is included in the LICENSE file that* accompanied this code).** You should have received a copy of the GNU General Public License version* 2 along with this work; if not, write to the Free Software Foundation,* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.** Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA* or visit www.oracle.com if you need additional information or have any* questions.*/

??那么如何在IntelliJ IDEA(下面简称IDEA)中添加类似上面这样的Copyright信息呢?接下来,我们就来介绍一下如何在在IntelliJ IDEA中添加Copyright信息。

??在IDEA中File > Settings … > Editor > Copyright > Copyright Profiles
这里写图片描述

这里写图片描述

这里写图片描述

这里写图片描述

www.qwfys.org Inc.
Copyright (c) 2004- $today.year All Rights Reserved.

这里写图片描述

Alt+Insert > Copyright

这里写图片描述

这里写图片描述

lwk@qwfys ~/Public/project/com/jetbrains/idea/helloworld $ tree -a
.
├── .gitignore
├── helloworld.iml
├── .idea
│   ├── compiler.xml
│   ├── copyright
│   │   ├── profiles_settings.xml
│   │   └── qwfys.xml
│   ├── encodings.xml
│   ├── libraries
│   │   ├── Maven__ch_qos_logback_logback_classic_1_2_3.xml
│   │   ├── Maven__ch_qos_logback_logback_core_1_2_3.xml
│   │   ├── Maven__com_fasterxml_classmate_1_3_4.xml
│   │   ├── Maven__com_fasterxml_jackson_core_jackson_annotations_2_9_0.xml
│   │   ├── Maven__com_fasterxml_jackson_core_jackson_core_2_9_5.xml
│   │   ├── Maven__com_fasterxml_jackson_core_jackson_databind_2_9_5.xml
│   │   ├── Maven__com_fasterxml_jackson_datatype_jackson_datatype_jdk8_2_9_5.xml
│   │   ├── Maven__com_fasterxml_jackson_datatype_jackson_datatype_jsr310_2_9_5.xml
│   │   ├── Maven__com_fasterxml_jackson_module_jackson_module_parameter_names_2_9_5.xml
│   │   ├── Maven__com_jayway_jsonpath_json_path_2_4_0.xml
│   │   ├── Maven__com_vaadin_external_google_android_json_0_0_20131108_vaadin1.xml
│   │   ├── Maven__javax_annotation_javax_annotation_api_1_3_2.xml
│   │   ├── Maven__javax_validation_validation_api_2_0_1_Final.xml
│   │   ├── Maven__junit_junit_4_12.xml
│   │   ├── Maven__net_bytebuddy_byte_buddy_1_7_11.xml
│   │   ├── Maven__net_bytebuddy_byte_buddy_agent_1_7_11.xml
│   │   ├── Maven__net_minidev_accessors_smart_1_2.xml
│   │   ├── Maven__net_minidev_json_smart_2_3.xml
│   │   ├── Maven__org_apache_logging_log4j_log4j_api_2_10_0.xml
│   │   ├── Maven__org_apache_logging_log4j_log4j_to_slf4j_2_10_0.xml
│   │   ├── Maven__org_apache_tomcat_embed_tomcat_embed_core_8_5_31.xml
│   │   ├── Maven__org_apache_tomcat_embed_tomcat_embed_el_8_5_31.xml
│   │   ├── Maven__org_apache_tomcat_embed_tomcat_embed_websocket_8_5_31.xml
│   │   ├── Maven__org_assertj_assertj_core_3_9_1.xml
│   │   ├── Maven__org_hamcrest_hamcrest_core_1_3.xml
│   │   ├── Maven__org_hamcrest_hamcrest_library_1_3.xml
│   │   ├── Maven__org_hibernate_validator_hibernate_validator_6_0_9_Final.xml
│   │   ├── Maven__org_jboss_logging_jboss_logging_3_3_2_Final.xml
│   │   ├── Maven__org_mockito_mockito_core_2_15_0.xml
│   │   ├── Maven__org_objenesis_objenesis_2_6.xml
│   │   ├── Maven__org_ow2_asm_asm_5_0_4.xml
│   │   ├── Maven__org_skyscreamer_jsonassert_1_5_0.xml
│   │   ├── Maven__org_slf4j_jul_to_slf4j_1_7_25.xml
│   │   ├── Maven__org_slf4j_slf4j_api_1_7_25.xml
│   │   ├── Maven__org_springframework_boot_spring_boot_2_0_2_RELEASE.xml
│   │   ├── Maven__org_springframework_boot_spring_boot_autoconfigure_2_0_2_RELEASE.xml
│   │   ├── Maven__org_springframework_boot_spring_boot_devtools_2_0_2_RELEASE.xml
│   │   ├── Maven__org_springframework_boot_spring_boot_starter_2_0_2_RELEASE.xml
│   │   ├── Maven__org_springframework_boot_spring_boot_starter_json_2_0_2_RELEASE.xml
│   │   ├── Maven__org_springframework_boot_spring_boot_starter_logging_2_0_2_RELEASE.xml
│   │   ├── Maven__org_springframework_boot_spring_boot_starter_test_2_0_2_RELEASE.xml
│   │   ├── Maven__org_springframework_boot_spring_boot_starter_tomcat_2_0_2_RELEASE.xml
│   │   ├── Maven__org_springframework_boot_spring_boot_starter_web_2_0_2_RELEASE.xml
│   │   ├── Maven__org_springframework_boot_spring_boot_test_2_0_2_RELEASE.xml
│   │   ├── Maven__org_springframework_boot_spring_boot_test_autoconfigure_2_0_2_RELEASE.xml
│   │   ├── Maven__org_springframework_spring_aop_5_0_6_RELEASE.xml
│   │   ├── Maven__org_springframework_spring_beans_5_0_6_RELEASE.xml
│   │   ├── Maven__org_springframework_spring_context_5_0_6_RELEASE.xml
│   │   ├── Maven__org_springframework_spring_core_5_0_6_RELEASE.xml
│   │   ├── Maven__org_springframework_spring_expression_5_0_6_RELEASE.xml
│   │   ├── Maven__org_springframework_spring_jcl_5_0_6_RELEASE.xml
│   │   ├── Maven__org_springframework_spring_test_5_0_6_RELEASE.xml
│   │   ├── Maven__org_springframework_spring_web_5_0_6_RELEASE.xml
│   │   ├── Maven__org_springframework_spring_webmvc_5_0_6_RELEASE.xml
│   │   ├── Maven__org_xmlunit_xmlunit_core_2_5_1.xml
│   │   └── Maven__org_yaml_snakeyaml_1_19.xml
│   ├── misc.xml
│   ├── modules.xml
│   └── workspace.xml
├── .mvn
│   └── wrapper
│       ├── maven-wrapper.jar
│       └── maven-wrapper.properties
├── mvnw
├── mvnw.cmd
├── pom.xml
└── src├── main│   ├── java│   │   └── helloworld│   │       └── helloworld│   │           └── HelloworldApplication.java│   └── resources│       ├── application.properties│       ├── static│       └── templates└── test└── java└── helloworld└── helloworld└── HelloworldApplicationTests.java17 directories, 73 files
lwk@qwfys ~/Public/project/com/jetbrains/idea/helloworld $ 

我们看到,刚才添加的Copyrightm出现在了目录./.idea/copyright。

lwk@qwfys ~/Public/project/com/jetbrains/idea/helloworld $ more .idea/copyright/qwfys.xml 
<component name="CopyrightManager"><copyright><option name="notice" value="www.qwfys.org Inc.&#10;Copyright (c) 2004- &amp;#36;today.year All Rights Reserved." /><option name="myName" value="qwfys" /></copyright>
</component>
lwk@qwfys ~/Public/project/com/jetbrains/idea/helloworld $ 
lwk@qwfys ~/Public/project/com/jetbrains/idea/helloworld $ more .idea/copyright/profiles_settings.xml 
<component name="CopyrightManager"><settings default="qwfys"><module2copyright><element module="All" copyright="qwfys" /></module2copyright></settings>
</component>
lwk@qwfys ~/Public/project/com/jetbrains/idea/helloworld $ 

??我们看到,只要将copyright目录放到IntelliJ IDEA项目根目录下的.idea目录下就可以了让当前项目具备添加Copyright信息的能力了。

参考文献

  • IntelliJ IDEA 2018.1 Help / Copyright Profiles
  相关解决方案