mybatis-plus代码生成器如何设置自动生成的文件名
时间: 2023-11-17 08:24:33 浏览: 76
mybatis-plus的代码生成器可以通过修改代码模板文件来设置自动生成的文件名。
1. 找到mybatis-plus-generator项目的resources/templates目录下的代码模板文件。
2. 打开对应的模板文件,例如entity.java.vm。
3. 在模板文件中找到生成的文件名部分,一般在开头的地方,例如:
```
package ${package};
${importList}
/**
* ${tableComment}(${tableName})实体类
* @since ${nowDate}
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
public class ${className} extends Model<${className}> {
private static final long serialVersionUID = 1L;
<% for(column in table.columns){ %>
/**
* ${column.columnComment}
*/
private ${column.javaType} ${column.fieldName};
<% } %>
}
```
4. 修改${className}部分即可改变生成的文件名,例如修改为${className}Entity:
```
package ${package};
${importList}
/**
* ${tableComment}(${tableName})实体类
* @since ${nowDate}
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
public class ${className}Entity extends Model<${className}Entity> {
private static final long serialVersionUID = 1L;
<% for(column in table.columns){ %>
/**
* ${column.columnComment}
*/
private ${column.javaType} ${column.fieldName};
<% } %>
}
```
5. 保存修改后的代码模板文件即可。
相关推荐
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)