• 大小: 3.06MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-11-15
  • 语言: Java
  • 标签: mybatis  

资源简介

参考博客:http://blog.csdn.net/u014534808/article/details/78901371,自动生成Java代码,采用SSM框架,包括mapper,xml,service,controller,model

资源截图

代码片段和文件信息

package com.jay.generator;

import com.jay.generator.api.AutoGenerationJavaCodeUpgrade;
import freemarker.template.TemplateException;
import org.mybatis.generator.api.MyBatisGenerator;
import org.mybatis.generator.config.Configuration;
import org.mybatis.generator.config.Context;
import org.mybatis.generator.config.TableConfiguration;
import org.mybatis.generator.config.xml.ConfigurationParser;
import org.mybatis.generator.exception.InvalidConfigurationException;
import org.mybatis.generator.exception.xmlParserException;
import org.mybatis.generator.internal.DefaultShellCallback;

import java.io.File;
import java.io.IOException;
import java.net.URISyntaxException;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

/**
 * @author generator.wei
 * @create 2017/12/7 15:45
 */
public class GeneratorStartUp {

    /**
     * @param args
     * @throws URISyntaxException
     *
     */
    public static void main(String[] args) throws URISyntaxException {
        try {
            AutoGenerationJavaCodeUpgrade autoGenerationJavaCodeUpgrade = new AutoGenerationJavaCodeUpgrade();
            //获取service,controller包名
            String servicePackageName = autoGenerationJavaCodeUpgrade.getServicePackageName();
            //得到包路径
            String servicePackagePath = servicePackageName.replace(“.““/“);
            List warnings = new ArrayList();
            boolean overwrite = true;
            // 1、生成xml Map Model
            //直接获取generatorConfig.xml的文件路径 根据具体情况查看
            File configFile = new File(System.getProperty(“user.dir“) + “/auto-java-code-upgrade/src/main/resources/generatorConfig.xml“);
            ConfigurationParser cp = new ConfigurationParser(warnings);
            Configuration config = cp.parseConfiguration(configFile);
            DefaultShellCallback callback = new DefaultShellCallback(overwrite);
            MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config callback warnings);
            myBatisGenerator.generate(null);
            //获取包路径
            List contexts = config.getContexts();
            if (contexts == null || contexts.size() == 0) {
                return;
            }
            for (Context context : contexts) {
                List tableConfigurations = context.getTableConfigurations();
                if (tableConfigurations != null && tableConfigurations.size() > 0) {
                    for (TableConfiguration tableConfiguration : tableConfigurations) {
                        //获取实体类类名
                        String domainobjectName=tableConfiguration.getDomainobjectName();
                        String first = domainobjectName.substring(0 1).toLowerCase();
                        String rest = domainobjectName.substring(1);
                        domainobjectName = first + rest;
                        //生成service
                        autoGe

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       2879  2017-12-26 13:19  auto-java-code-upgrade\auto-java-code-upgrade.iml

     文件       3616  2017-12-26 09:23  auto-java-code-upgrade\pom.xml

     文件       2255  2017-12-26 13:42  auto-java-code-upgrade\README.md

     文件       1491  2017-12-22 09:37  auto-java-code-upgrade\src\main\doc\data.sql

     文件       4056  2017-12-26 09:48  auto-java-code-upgrade\src\main\java\com\jay\generator\api\AutoGenerationJavaCodeUpgrade.java

     文件       2421  2017-12-25 17:01  auto-java-code-upgrade\src\main\java\com\jay\generator\api\MyPluginAdapter.java

     文件        473  2017-12-26 11:13  auto-java-code-upgrade\src\main\java\com\jay\generator\codegen\mybatis3\controller\ControllerGenerator.java

     文件       1077  2017-12-25 15:53  auto-java-code-upgrade\src\main\java\com\jay\generator\codegen\mybatis3\javamapper\elements\CountListMethodGenerator.java

     文件       1601  2017-12-25 16:04  auto-java-code-upgrade\src\main\java\com\jay\generator\codegen\mybatis3\javamapper\elements\QueryPageListMethodGenerator.java

     文件        363  2017-12-25 09:19  auto-java-code-upgrade\src\main\java\com\jay\generator\codegen\mybatis3\javamapper\MySimpleAnnotatedClientGenerator.java

     文件       4006  2017-12-25 16:24  auto-java-code-upgrade\src\main\java\com\jay\generator\codegen\mybatis3\javamapper\MySimpleJavaClientGenerator.java

     文件        343  2017-12-25 09:19  auto-java-code-upgrade\src\main\java\com\jay\generator\codegen\mybatis3\model\MySimpleModelGenerator.java

     文件       2673  2017-12-26 11:17  auto-java-code-upgrade\src\main\java\com\jay\generator\codegen\mybatis3\MyIntrospectedTableMyBatis3SimpleImpl.java

     文件       3118  2017-12-25 16:45  auto-java-code-upgrade\src\main\java\com\jay\generator\codegen\mybatis3\service\ServiceGenerator.java

     文件       1119  2017-12-25 15:53  auto-java-code-upgrade\src\main\java\com\jay\generator\codegen\mybatis3\xmlmapper\elements\MySimpleCountListElementGenerator.java

     文件       1585  2017-12-25 15:39  auto-java-code-upgrade\src\main\java\com\jay\generator\codegen\mybatis3\xmlmapper\elements\MySimpleQueryPageListElementGenerator.java

     文件       2465  2017-12-25 15:41  auto-java-code-upgrade\src\main\java\com\jay\generator\codegen\mybatis3\xmlmapper\MySimplexmlMapperGenerator.java

     文件       3905  2017-12-26 10:17  auto-java-code-upgrade\src\main\java\com\jay\generator\GeneratorStartUp.java

     文件       7090  2017-12-25 09:19  auto-java-code-upgrade\src\main\java\com\jay\generator\internal\MyCommentGenerator.java

     文件       2589  2017-12-25 09:19  auto-java-code-upgrade\src\main\java\com\jay\generator\pagehelper\PageInfo.java

     文件       1037  2017-12-26 14:02  auto-java-code-upgrade\src\main\java\com\jay\spring\boot\mapper\ShDepartmentMapper.java

     文件       1017  2017-12-26 14:02  auto-java-code-upgrade\src\main\java\com\jay\spring\boot\mapper\ShEmployeeMapper.java

     文件       1143  2017-12-26 14:02  auto-java-code-upgrade\src\main\java\com\jay\spring\boot\model\ShDepartment.java

     文件       3393  2017-12-26 14:02  auto-java-code-upgrade\src\main\java\com\jay\spring\boot\model\ShEmployee.java

     文件       1704  2017-12-26 14:02  auto-java-code-upgrade\src\main\java\com\jay\spring\boot\mybatis\ShDepartmentMapper.xml

     文件       2724  2017-12-26 14:02  auto-java-code-upgrade\src\main\java\com\jay\spring\boot\mybatis\ShEmployeeMapper.xml

     文件       1848  2017-12-26 14:02  auto-java-code-upgrade\src\main\java\com\jay\spring\boot\service\ShDepartmentController.java

     文件        646  2017-12-26 14:02  auto-java-code-upgrade\src\main\java\com\jay\spring\boot\service\ShDepartmentService.java

     文件       1374  2017-12-26 14:02  auto-java-code-upgrade\src\main\java\com\jay\spring\boot\service\ShDepartmentServiceImpl.java

     文件       1804  2017-12-26 14:02  auto-java-code-upgrade\src\main\java\com\jay\spring\boot\service\ShEmployeeController.java

............此处省略94个文件信息

评论

共有 条评论