当前位置:   article > 正文

mybatis-plus-generator-ui

mybatis-plus-generator-ui

官方地址:https://github.com/davidfantasy/mybatis-plus-generator-ui
建立springboot项目,pom添加依赖

<dependency>
            <groupId>com.github.davidfantasy</groupId>
            <artifactId>mybatis-plus-generator-ui</artifactId>
            <version>2.0.5</version>
            <scope>compile</scope>
        </dependency>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

新建类:GeberatorUIServer,修改BASEPACKAGE_NAME、DATABASES_URL、DATABASES_NAME、DATABASES_PASSWORD常量的值

package com.example.uiodemo;

import com.github.davidfantasy.mybatisplus.generatorui.GeneratorConfig;
import com.github.davidfantasy.mybatisplus.generatorui.MybatisPlusToolsApplication;
import com.github.davidfantasy.mybatisplus.generatorui.mbp.NameConverter;

/**
 * @ClassName GeberatorUIServer
 * @Description TODO
 * @Author lihao
 * @Date 2023/12/21 16:03
 * @Version 1.0
 */
public class GeberatorUIServer {
    private static final String BASEPACKAGE_NAME = "com.example.uiodemo";
    private static final String DATABASES_URL = "jdbc:mysql://localhost:3306/nnblog";
    private static final String DATABASES_NAME = "root";
    private static final String DATABASES_PASSWORD = "root";
    public static void main(String[] args) {
        GeneratorConfig config = GeneratorConfig.builder().jdbcUrl(DATABASES_URL)
                .userName(DATABASES_NAME)
                .password(DATABASES_PASSWORD)
                .driverClassName("com.mysql.cj.jdbc.Driver")
                //数据库schema,MSSQL,PGSQL,ORACLE,DB2类型的数据库需要指定
                .schemaName("nnblog")
                //数据库表前缀,生成entity名称时会去掉(v2.0.3新增)
                .tablePrefix("t_")
                //如果需要修改entity及其属性的命名规则,以及自定义各类生成文件的命名规则,可自定义一个NameConverter实例,覆盖相应的名称转换方法,详细可查看该接口的说明:
                .nameConverter(new NameConverter() {
                    /**
                     * 自定义Service类文件的名称规则,entityName是NameConverter.entityNameConvert处理表名后的返回结果,如有特别的需求可以自定义实现
                     */
                    @Override
                    public String serviceNameConvert(String entityName) {
                        return entityName + "Service";
                    }

                    /**
                     * 自定义Controller类文件的名称规则
                     */
                    @Override
                    public String controllerNameConvert(String entityName) {
                        return entityName + "Action";
                    }
                })
                //所有生成的java文件的父包名,后续也可单独在界面上设置
                .basePackage(BASEPACKAGE_NAME)
                .port(8068)
                .build();
        MybatisPlusToolsApplication.run(config);
    }
}

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53

运行main方法

"C:\Program Files\Java\jdk-17\bin\java.exe" "-javaagent:F:\idea\IntelliJ IDEA 2023.3.2\lib\idea_rt.jar=10088:F:\idea\IntelliJ IDEA 2023.3.2\bin" -Dfile.encoding=UTF-8 -classpath F:\idea\workspaces\uiodemo\target\classes;F:\maven\.m2\repository\org\springframework\boot\spring-boot-starter-thymeleaf\3.2.0\spring-boot-starter-thymeleaf-3.2.0.jar;F:\maven\.m2\repository\org\springframework\boot\spring-boot-starter\3.2.0\spring-boot-starter-3.2.0.jar;F:\maven\.m2\repository\org\springframework\boot\spring-boot\3.2.0\spring-boot-3.2.0.jar;F:\maven\.m2\repository\org\springframework\spring-context\6.1.1\spring-context-6.1.1.jar;F:\maven\.m2\repository\org\springframework\boot\spring-boot-autoconfigure\3.2.0\spring-boot-autoconfigure-3.2.0.jar;F:\maven\.m2\repository\org\springframework\boot\spring-boot-starter-logging\3.2.0\spring-boot-starter-logging-3.2.0.jar;F:\maven\.m2\repository\ch\qos\logback\logback-classic\1.4.11\logback-classic-1.4.11.jar;F:\maven\.m2\repository\ch\qos\logback\logback-core\1.4.11\logback-core-1.4.11.jar;F:\maven\.m2\repository\org\apache\logging\log4j\log4j-to-slf4j\2.21.1\log4j-to-slf4j-2.21.1.jar;F:\maven\.m2\repository\org\apache\logging\log4j\log4j-api\2.21.1\log4j-api-2.21.1.jar;F:\maven\.m2\repository\org\slf4j\jul-to-slf4j\2.0.9\jul-to-slf4j-2.0.9.jar;F:\maven\.m2\repository\jakarta\annotation\jakarta.annotation-api\2.1.1\jakarta.annotation-api-2.1.1.jar;F:\maven\.m2\repository\org\yaml\snakeyaml\2.2\snakeyaml-2.2.jar;F:\maven\.m2\repository\org\thymeleaf\thymeleaf-spring6\3.1.2.RELEASE\thymeleaf-spring6-3.1.2.RELEASE.jar;F:\maven\.m2\repository\org\thymeleaf\thymeleaf\3.1.2.RELEASE\thymeleaf-3.1.2.RELEASE.jar;F:\maven\.m2\repository\org\attoparser\attoparser\2.0.7.RELEASE\attoparser-2.0.7.RELEASE.jar;F:\maven\.m2\repository\org\unbescape\unbescape\1.1.6.RELEASE\unbescape-1.1.6.RELEASE.jar;F:\maven\.m2\repository\org\slf4j\slf4j-api\2.0.9\slf4j-api-2.0.9.jar;F:\maven\.m2\repository\com\mysql\mysql-connector-j\8.1.0\mysql-connector-j-8.1.0.jar;F:\maven\.m2\repository\org\springframework\spring-core\6.1.1\spring-core-6.1.1.jar;F:\maven\.m2\repository\org\springframework\spring-jcl\6.1.1\spring-jcl-6.1.1.jar;F:\maven\.m2\repository\com\github\davidfantasy\mybatis-plus-generator-ui\2.0.5\mybatis-plus-generator-ui-2.0.5.jar;F:\maven\.m2\repository\org\springframework\boot\spring-boot-starter-web\3.2.0\spring-boot-starter-web-3.2.0.jar;F:\maven\.m2\repository\org\springframework\boot\spring-boot-starter-json\3.2.0\spring-boot-starter-json-3.2.0.jar;F:\maven\.m2\repository\com\fasterxml\jackson\core\jackson-databind\2.15.3\jackson-databind-2.15.3.jar;F:\maven\.m2\repository\com\fasterxml\jackson\core\jackson-annotations\2.15.3\jackson-annotations-2.15.3.jar;F:\maven\.m2\repository\com\fasterxml\jackson\core\jackson-core\2.15.3\jackson-core-2.15.3.jar;F:\maven\.m2\repository\com\fasterxml\jackson\datatype\jackson-datatype-jdk8\2.15.3\jackson-datatype-jdk8-2.15.3.jar;F:\maven\.m2\repository\com\fasterxml\jackson\datatype\jackson-datatype-jsr310\2.15.3\jackson-datatype-jsr310-2.15.3.jar;F:\maven\.m2\repository\com\fasterxml\jackson\module\jackson-module-parameter-names\2.15.3\jackson-module-parameter-names-2.15.3.jar;F:\maven\.m2\repository\org\springframework\boot\spring-boot-starter-tomcat\3.2.0\spring-boot-starter-tomcat-3.2.0.jar;F:\maven\.m2\repository\org\apache\tomcat\embed\tomcat-embed-core\10.1.16\tomcat-embed-core-10.1.16.jar;F:\maven\.m2\repository\org\apache\tomcat\embed\tomcat-embed-el\10.1.16\tomcat-embed-el-10.1.16.jar;F:\maven\.m2\repository\org\apache\tomcat\embed\tomcat-embed-websocket\10.1.16\tomcat-embed-websocket-10.1.16.jar;F:\maven\.m2\repository\org\springframework\spring-web\6.1.1\spring-web-6.1.1.jar;F:\maven\.m2\repository\org\springframework\spring-beans\6.1.1\spring-beans-6.1.1.jar;F:\maven\.m2\repository\io\micrometer\micrometer-observation\1.12.0\micrometer-observation-1.12.0.jar;F:\maven\.m2\repository\io\micrometer\micrometer-commons\1.12.0\micrometer-commons-1.12.0.jar;F:\maven\.m2\repository\org\springframework\spring-webmvc\6.1.1\spring-webmvc-6.1.1.jar;F:\maven\.m2\repository\org\springframework\spring-aop\6.1.1\spring-aop-6.1.1.jar;F:\maven\.m2\repository\org\springframework\spring-expression\6.1.1\spring-expression-6.1.1.jar;F:\maven\.m2\repository\org\springframework\boot\spring-boot-starter-jdbc\3.2.0\spring-boot-starter-jdbc-3.2.0.jar;F:\maven\.m2\repository\com\zaxxer\HikariCP\5.0.1\HikariCP-5.0.1.jar;F:\maven\.m2\repository\org\springframework\spring-jdbc\6.1.1\spring-jdbc-6.1.1.jar;F:\maven\.m2\repository\org\springframework\spring-tx\6.1.1\spring-tx-6.1.1.jar;F:\maven\.m2\repository\cn\hutool\hutool-core\5.8.12\hutool-core-5.8.12.jar;F:\maven\.m2\repository\com\baomidou\mybatis-plus-generator\3.5.3.1\mybatis-plus-generator-3.5.3.1.jar;F:\maven\.m2\repository\com\baomidou\mybatis-plus-annotation\3.5.3.1\mybatis-plus-annotation-3.5.3.1.jar;F:\maven\.m2\repository\com\baomidou\mybatis-plus-core\3.5.3.1\mybatis-plus-core-3.5.3.1.jar;F:\maven\.m2\repository\org\mybatis\mybatis\3.5.10\mybatis-3.5.10.jar;F:\maven\.m2\repository\com\ibeetl\beetl\3.15.4.RELEASE\beetl-3.15.4.RELEASE.jar;F:\maven\.m2\repository\org\antlr\antlr4-runtime\4.9.3\antlr4-runtime-4.9.3.jar;F:\maven\.m2\repository\com\ibeetl\beetl-core\3.15.4.RELEASE\beetl-core-3.15.4.RELEASE.jar;F:\maven\.m2\repository\com\ibeetl\beetl-default-antlr4.9-support\3.15.4.RELEASE\beetl-default-antlr4.9-support-3.15.4.RELEASE.jar;F:\maven\.m2\repository\com\ibeetl\beetl-ext\3.15.4.RELEASE\beetl-ext-3.15.4.RELEASE.jar;F:\maven\.m2\repository\org\dom4j\dom4j\2.1.3\dom4j-2.1.3.jar;F:\maven\.m2\repository\com\alibaba\druid\1.2.15\druid-1.2.15.jar;F:\maven\.m2\repository\com\github\jsqlparser\jsqlparser\4.4\jsqlparser-4.4.jar;F:\maven\.m2\repository\com\github\javaparser\javaparser-symbol-solver-core\3.24.10\javaparser-symbol-solver-core-3.24.10.jar;F:\maven\.m2\repository\com\github\javaparser\javaparser-core\3.24.10\javaparser-core-3.24.10.jar;F:\maven\.m2\repository\org\javassist\javassist\3.29.2-GA\javassist-3.29.2-GA.jar;F:\maven\.m2\repository\com\google\guava\guava\31.1-jre\guava-31.1-jre.jar;F:\maven\.m2\repository\com\google\guava\failureaccess\1.0.1\failureaccess-1.0.1.jar;F:\maven\.m2\repository\com\google\guava\listenablefuture\9999.0-empty-to-avoid-conflict-with-guava\listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar;F:\maven\.m2\repository\com\google\code\findbugs\jsr305\3.0.2\jsr305-3.0.2.jar;F:\maven\.m2\repository\org\checkerframework\checker-qual\3.12.0\checker-qual-3.12.0.jar;F:\maven\.m2\repository\com\google\errorprone\error_prone_annotations\2.11.0\error_prone_annotations-2.11.0.jar;F:\maven\.m2\repository\com\google\j2objc\j2objc-annotations\1.3\j2objc-annotations-1.3.jar com.example.uiodemo.GeberatorUIServer

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::                (v3.2.0)

2023-12-21T17:15:06.356+08:00  INFO 19488 --- [           main] com.example.uiodemo.GeberatorUIServer    : Starting GeberatorUIServer using Java 17.0.9 with PID 19488 (F:\idea\workspaces\uiodemo\target\classes started by Lihao1 in F:\idea\workspaces\uiodemo)
2023-12-21T17:15:06.360+08:00  INFO 19488 --- [           main] com.example.uiodemo.GeberatorUIServer    : No active profile set, falling back to 1 default profile: "default"
2023-12-21T17:15:07.101+08:00  INFO 19488 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port 8068 (http)
2023-12-21T17:15:07.112+08:00  INFO 19488 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2023-12-21T17:15:07.112+08:00  INFO 19488 --- [           main] o.apache.catalina.core.StandardEngine    : Starting Servlet engine: [Apache Tomcat/10.1.16]
2023-12-21T17:15:07.195+08:00  INFO 19488 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2023-12-21T17:15:07.196+08:00  INFO 19488 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 806 ms
2023-12-21T17:15:07.303+08:00  INFO 19488 --- [           main] c.g.d.m.g.mbp.BeetlTemplateEngine        : 模板根目录为:C:\Users\Lihao1\.mybatis-plus-generator-ui\com.example.uiodemo\template
2023-12-21T17:15:07.463+08:00  INFO 19488 --- [           main] o.s.b.a.w.s.WelcomePageHandlerMapping    : Adding welcome page: class path resource [public/index.html]
2023-12-21T17:15:07.615+08:00  INFO 19488 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port 8068 (http) with context path ''
2023-12-21T17:15:07.618+08:00  INFO 19488 --- [           main] com.example.uiodemo.GeberatorUIServer    : Started GeberatorUIServer in 1.551 seconds (process running for 1.872)

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22

浏览器访问地址:http://localhost:8068/,即可正常显示页面
在这里插入图片描述
点击配置,可以更改路径,模板,选择表,生成代码即可

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/AllinToyou/article/detail/231118
推荐阅读
相关标签
  

闽ICP备14008679号