[英]IntelliJ IDEA File Templates - Customize directory/package for Multiple Files Template
I'm using IntelliJ IDEA to develop a Java app.我正在使用 IntelliJ IDEA 开发 Java 应用程序。
Let's suppose I have a Multiple File Template that creates a Model Entity, Service and a Controller.假设我有一个多文件模板,它创建了一个 Model 实体、服务和一个 Controller。
When I use that template, 3 files are created in the same location
.当我使用该模板时,会
in the same location
创建 3 个文件。 Assume that the Entity name is Car
, then the files would be:假设实体名称是
Car
,那么文件将是:
Assuming the following structure...假设以下结构...
--+ app
+-- model
+-- service
+-- controller
How can I define the location where each files gets created, so the result would be like:如何定义创建每个文件的位置,结果如下:
--+ app
+--+ model
+-- Car
+--+ service
+-- CarService
+--+ controller
+-- CarController
You can specify folders in the file name of the template.您可以在模板的文件名中指定文件夹。 For example your main template can have the file name
model/${NAME}
and below it you can define two child templates with file names service/${NAME}Service
and controller/${NAME}Controller
.例如,您的主模板可以有文件名
model/${NAME}
,在它下面您可以定义两个子模板,文件名是service/${NAME}Service
和controller/${NAME}Controller
。 When the template is used this will create the folders if necessary, or use existing folders if they are already present.使用模板时,这将在必要时创建文件夹,或者使用现有文件夹(如果它们已经存在)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.