Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

如何控制生成的model名 #32

Closed
anchuang opened this issue Jul 21, 2017 · 4 comments
Closed

如何控制生成的model名 #32

anchuang opened this issue Jul 21, 2017 · 4 comments

Comments

@anchuang
Copy link

一般在建表的时候都会加上前缀 t_ ,针对这个问题应该怎么解决。

@lihengming
Copy link
Owner

@anchuang HI,最近比较忙,没来的及答复,不好意思。这个问题刚才我已经解决,并加到CodeGenerator上了,可以自己指定 Model 的名称了,请更新代码。

public static void main(String[] args) {
    genCode("输入表名","输入自定义Model名称");
}

/**
 * 通过数据表名称,和自定义的 Model 名称生成代码
 * 如输入表名称 "t_user_detail" 和自定义的 Model 名称 "User" 将生成 User、UserMapper、UserService ...
 * @param tableName 数据表名称
 * @param modelName 自定义的 Model 名称
 */
public static void genCode(String tableName, String modelName) {
    genModelAndMapper(tableName, modelName);
    genService(tableName, modelName);
    genController(tableName, modelName);
}

@lihengming lihengming self-assigned this Jul 26, 2017
@anchuang
Copy link
Author

谢谢,测试了下,这个问题已经得到了解决。能否把生成mapper.xml和生成model的模板也放在template目录下下,这样方便根据本身的项目需要修改。

@lihengming
Copy link
Owner

@anchuang HI,Model 和 Mapper 是用 MyBatis Generator 生成的,相关配置可以查看官方文档:http://www.mybatis.org/generator/

@anchuang
Copy link
Author

收到,谢谢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants