一、项目说明
该项目MyBatis-Plus 的代码生成器AutoGenerator代码示例,可以快速生成 Entity、Mapper、Mapper XML、Service、Controller 等各个模块的代码。具体项目代码结构如下
构建说明:
1)项目maven-settings.xml配置maven设置@b@2)sqljdbc4-4.0.jar 不太容易找到,直接手动项目路径依赖包@b@3)README.md 安装配置说明
注意:sqljdbc4-4.0.jar 下载 (pom更多下载)
二、代码生成测试
1)运行AutoGeneratorApplication启动类
D:\apps\jdk\jdk1.8.0_221\bin\java.exe -XX:TieredStopAtLevel=1 -noverify -Dspring.output.ansi.enabled=always -Dcom.sun.management.jmxremote -Dspring.jmx.enabled=true -Dspring.liveBeansView.mbeanDomain -Dspring.application.admin.enabled=true "-javaagent:D:\tool\JetBrains\IntelliJ IDEA 2020.1\lib\idea_rt.jar=63163:D:\tool\JetBrains\IntelliJ IDEA 2020.1\bin" -Dfile.encoding=UTF-8 -classpath D:\apps\jdk\jdk1.8.0_221\jre\lib\charsets.jar;D:\apps\jdk\jdk1.8.0_221\jre\lib\deploy.jar;D:\apps\jdk\jdk1.8.0_221\jre\lib\ext\access-bridge-64.jar;D:\apps\jdk\jdk1.8.0_221\jre\lib\ext\cldrdata.jar;D:\apps\jdk\jdk1.8.0_221\jre\lib\ext\dnsns.jar;D:\apps\jdk\jdk1.8.0_221\jre\lib\ext\jaccess.jar;D:\apps\jdk\jdk1.8.0_221\jre\lib\ext\jfxrt.jar;D:\apps\jdk\jdk1.8.0_221\jre\lib\ext\localedata.jar;D:\apps\jdk\jdk1.8.0_221\jre\lib\ext\nashorn.jar;D:\apps\jdk\jdk1.8.0_221\jre\lib\ext\sunec.jar;D:\apps\jdk\jdk1.8.0_221\jre\lib\ext\sunjce_provider.jar;D:\apps\jdk\jdk1.8.0_221\jre\lib\ext\sunmscapi.jar;D:\apps\jdk\jdk1.8.0_221\jre\lib\ext\sunpkcs11.jar;D:\apps\jdk\jdk1.8.0_221\jre\lib\ext\zipfs.jar;D:\apps\jdk\jdk1.8.0_221\jre\lib\javaws.jar;D:\apps\jdk\jdk1.8.0_221\jre\lib\jce.jar;D:\apps\jdk\jdk1.8.0_221\jre\lib\jfr.jar;D:\apps\jdk\jdk1.8.0_221\jre\lib\jfxswt.jar;D:\apps\jdk\jdk1.8.0_221\jre\lib\jsse.jar;D:\apps\jdk\jdk1.8.0_221\jre\lib\management-agent.jar;D:\apps\jdk\jdk1.8.0_221\jre\lib\plugin.jar;D:\apps\jdk\jdk1.8.0_221\jre\lib\resources.jar;D:\apps\jdk\jdk1.8.0_221\jre\lib\rt.jar;E:\maven-ws\auto-generator-master\target\classes;E:\Repository\Jar\org\springframework\boot\spring-boot-starter\2.4.3\spring-boot-starter-2.4.3.jar;E:\Repository\Jar\org\springframework\boot\spring-boot-starter-logging\2.4.3\spring-boot-starter-logging-2.4.3.jar;E:\Repository\Jar\ch\qos\logback\logback-classic\1.2.3\logback-classic-1.2.3.jar;E:\Repository\Jar\ch\qos\logback\logback-core\1.2.3\logback-core-1.2.3.jar;E:\Repository\Jar\org\apache\logging\log4j\log4j-to-slf4j\2.13.3\log4j-to-slf4j-2.13.3.jar;E:\Repository\Jar\org\apache\logging\log4j\log4j-api\2.13.3\log4j-api-2.13.3.jar;E:\Repository\Jar\org\slf4j\jul-to-slf4j\1.7.30\jul-to-slf4j-1.7.30.jar;E:\Repository\Jar\jakarta\annotation\jakarta.annotation-api\1.3.5\jakarta.annotation-api-1.3.5.jar;E:\Repository\Jar\org\yaml\snakeyaml\1.27\snakeyaml-1.27.jar;E:\Repository\Jar\org\slf4j\slf4j-api\1.7.30\slf4j-api-1.7.30.jar;E:\Repository\Jar\org\springframework\spring-core\5.3.4\spring-core-5.3.4.jar;E:\Repository\Jar\org\springframework\spring-jcl\5.3.4\spring-jcl-5.3.4.jar;E:\Repository\Jar\org\springframework\boot\spring-boot-starter-web\2.4.3\spring-boot-starter-web-2.4.3.jar;E:\Repository\Jar\org\springframework\boot\spring-boot-starter-json\2.4.3\spring-boot-starter-json-2.4.3.jar;E:\Repository\Jar\com\fasterxml\jackson\core\jackson-databind\2.11.4\jackson-databind-2.11.4.jar;E:\Repository\Jar\com\fasterxml\jackson\core\jackson-annotations\2.11.4\jackson-annotations-2.11.4.jar;E:\Repository\Jar\com\fasterxml\jackson\core\jackson-core\2.11.4\jackson-core-2.11.4.jar;E:\Repository\Jar\com\fasterxml\jackson\datatype\jackson-datatype-jdk8\2.11.4\jackson-datatype-jdk8-2.11.4.jar;E:\Repository\Jar\com\fasterxml\jackson\datatype\jackson-datatype-jsr310\2.11.4\jackson-datatype-jsr310-2.11.4.jar;E:\Repository\Jar\com\fasterxml\jackson\module\jackson-module-parameter-names\2.11.4\jackson-module-parameter-names-2.11.4.jar;E:\Repository\Jar\org\springframework\boot\spring-boot-starter-tomcat\2.4.3\spring-boot-starter-tomcat-2.4.3.jar;E:\Repository\Jar\org\apache\tomcat\embed\tomcat-embed-core\9.0.43\tomcat-embed-core-9.0.43.jar;E:\Repository\Jar\org\glassfish\jakarta.el\3.0.3\jakarta.el-3.0.3.jar;E:\Repository\Jar\org\apache\tomcat\embed\tomcat-embed-websocket\9.0.43\tomcat-embed-websocket-9.0.43.jar;E:\Repository\Jar\org\springframework\spring-web\5.3.4\spring-web-5.3.4.jar;E:\Repository\Jar\org\springframework\spring-beans\5.3.4\spring-beans-5.3.4.jar;E:\Repository\Jar\org\springframework\spring-webmvc\5.3.4\spring-webmvc-5.3.4.jar;E:\Repository\Jar\org\springframework\spring-aop\5.3.4\spring-aop-5.3.4.jar;E:\Repository\Jar\org\springframework\spring-context\5.3.4\spring-context-5.3.4.jar;E:\Repository\Jar\org\springframework\spring-expression\5.3.4\spring-expression-5.3.4.jar;E:\Repository\Jar\com\baomidou\mybatis-plus-boot-starter\3.3.1\mybatis-plus-boot-starter-3.3.1.jar;E:\Repository\Jar\com\baomidou\mybatis-plus\3.3.1\mybatis-plus-3.3.1.jar;E:\Repository\Jar\com\baomidou\mybatis-plus-extension\3.3.1\mybatis-plus-extension-3.3.1.jar;E:\Repository\Jar\com\baomidou\mybatis-plus-core\3.3.1\mybatis-plus-core-3.3.1.jar;E:\Repository\Jar\com\baomidou\mybatis-plus-annotation\3.3.1\mybatis-plus-annotation-3.3.1.jar;E:\Repository\Jar\org\mybatis\mybatis\3.5.3\mybatis-3.5.3.jar;E:\Repository\Jar\org\mybatis\mybatis-spring\2.0.3\mybatis-spring-2.0.3.jar;E:\Repository\Jar\org\springframework\boot\spring-boot-autoconfigure\2.4.3\spring-boot-autoconfigure-2.4.3.jar;E:\Repository\Jar\org\springframework\boot\spring-boot-starter-jdbc\2.4.3\spring-boot-starter-jdbc-2.4.3.jar;E:\Repository\Jar\com\zaxxer\HikariCP\3.4.5\HikariCP-3.4.5.jar;E:\Repository\Jar\org\springframework\spring-jdbc\5.3.4\spring-jdbc-5.3.4.jar;E:\Repository\Jar\org\springframework\spring-tx\5.3.4\spring-tx-5.3.4.jar;E:\Repository\Jar\com\alibaba\druid\1.1.13\druid-1.1.13.jar;E:\Repository\Jar\commons-lang\commons-lang\2.6\commons-lang-2.6.jar;E:\Repository\Jar\commons-io\commons-io\2.5\commons-io-2.5.jar;E:\Repository\Jar\commons-configuration\commons-configuration\1.10\commons-configuration-1.10.jar;E:\Repository\Jar\commons-logging\commons-logging\1.1.1\commons-logging-1.1.1.jar;E:\Repository\Jar\com\alibaba\fastjson\1.2.60\fastjson-1.2.60.jar;E:\Repository\Jar\org\apache\velocity\velocity\1.7\velocity-1.7.jar;E:\Repository\Jar\commons-collections\commons-collections\3.2.1\commons-collections-3.2.1.jar;E:\Repository\Jar\com\github\pagehelper\pagehelper-spring-boot-starter\1.2.5\pagehelper-spring-boot-starter-1.2.5.jar;E:\Repository\Jar\org\mybatis\spring\boot\mybatis-spring-boot-starter\1.3.2\mybatis-spring-boot-starter-1.3.2.jar;E:\Repository\Jar\org\mybatis\spring\boot\mybatis-spring-boot-autoconfigure\1.3.2\mybatis-spring-boot-autoconfigure-1.3.2.jar;E:\Repository\Jar\com\github\pagehelper\pagehelper-spring-boot-autoconfigure\1.2.5\pagehelper-spring-boot-autoconfigure-1.2.5.jar;E:\Repository\Jar\com\github\pagehelper\pagehelper\5.1.4\pagehelper-5.1.4.jar;E:\Repository\Jar\com\github\jsqlparser\jsqlparser\1.0\jsqlparser-1.0.jar;E:\Repository\Jar\mysql\mysql-connector-java\8.0.17\mysql-connector-java-8.0.17.jar;E:\Repository\Jar\com\oracle\ojdbc6\11.2.0.3\ojdbc6-11.2.0.3.jar;E:\Repository\Jar\org\postgresql\postgresql\42.2.18\postgresql-42.2.18.jar;E:\Repository\Jar\org\checkerframework\checker-qual\3.5.0\checker-qual-3.5.0.jar;E:\Repository\Jar\org\mongodb\mongo-java-driver\3.11.0\mongo-java-driver-3.11.0.jar;E:\Repository\Jar\org\projectlombok\lombok\1.18.8\lombok-1.18.8.jar;E:\Repository\Jar\org\springframework\boot\spring-boot-devtools\2.4.3\spring-boot-devtools-2.4.3.jar;E:\Repository\Jar\org\springframework\boot\spring-boot\2.4.3\spring-boot-2.4.3.jar;E:\Repository\Jar\com\microsoft\sqljdbc4\4.0\sqljdbc4-4.0.jar com.jobskrui.autogenerator.AutoGeneratorApplication@b@@b@ . ____ _ __ _ _@b@ /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \@b@( ( )\___ | '_ | '_| | '_ \/ _' | \ \ \ \@b@ \\/ ___)| |_)| | | | | || (_| | ) ) ) )@b@ ' |____| .__|_| |_|_| |_\__, | / / / /@b@ =========|_|==============|___/=/_/_/_/@b@ :: Spring Boot :: (v2.4.3)@b@@b@2022-11-19 01:16:21.410 INFO 10928 --- [ restartedMain] c.j.a.AutoGeneratorApplication : Starting AutoGeneratorApplication using Java 1.8.0_221 on DESKTOP-SIJ47KQ with PID 10928 (E:\maven-ws\auto-generator-master\target\classes started by Think in E:\maven-ws\auto-generator-master)@b@2022-11-19 01:16:21.414 INFO 10928 --- [ restartedMain] c.j.a.AutoGeneratorApplication : No active profile set, falling back to default profiles: default@b@2022-11-19 01:16:21.587 INFO 10928 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable@b@2022-11-19 01:16:21.587 INFO 10928 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'@b@2022-11-19 01:16:22.648 WARN 10928 --- [ restartedMain] o.m.s.mapper.ClassPathMapperScanner : Skipping MapperFactoryBean with name 'mySQLGeneratorDao' and 'com.jobskrui.autogenerator.dao.MySQLGeneratorDao' mapperInterface. Bean already defined with the same name!@b@2022-11-19 01:16:22.648 WARN 10928 --- [ restartedMain] o.m.s.mapper.ClassPathMapperScanner : Skipping MapperFactoryBean with name 'oracleGeneratorDao' and 'com.jobskrui.autogenerator.dao.OracleGeneratorDao' mapperInterface. Bean already defined with the same name!@b@2022-11-19 01:16:22.648 WARN 10928 --- [ restartedMain] o.m.s.mapper.ClassPathMapperScanner : Skipping MapperFactoryBean with name 'postgreSQLGeneratorDao' and 'com.jobskrui.autogenerator.dao.PostgreSQLGeneratorDao' mapperInterface. Bean already defined with the same name!@b@2022-11-19 01:16:22.648 WARN 10928 --- [ restartedMain] o.m.s.mapper.ClassPathMapperScanner : Skipping MapperFactoryBean with name 'SQLServerGeneratorDao' and 'com.jobskrui.autogenerator.dao.SQLServerGeneratorDao' mapperInterface. Bean already defined with the same name!@b@2022-11-19 01:16:23.259 INFO 10928 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8081 (http)@b@2022-11-19 01:16:23.270 INFO 10928 --- [ restartedMain] o.apache.catalina.core.StandardService : Starting service [Tomcat]@b@2022-11-19 01:16:23.271 INFO 10928 --- [ restartedMain] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.43]@b@2022-11-19 01:16:23.421 INFO 10928 --- [ restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext@b@2022-11-19 01:16:23.421 INFO 10928 --- [ restartedMain] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1832 ms@b@ _ _ |_ _ _|_. ___ _ | _ @b@| | |\/|_)(_| | |_\ |_)||_|_\ @b@ / | @b@ 3.3.1 @b@2022-11-19 01:16:25.732 INFO 10928 --- [ restartedMain] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'@b@2022-11-19 01:16:25.900 INFO 10928 --- [ restartedMain] o.s.b.a.w.s.WelcomePageHandlerMapping : Adding welcome page: class path resource [views/index.html]@b@2022-11-19 01:16:26.119 INFO 10928 --- [ restartedMain] o.s.b.d.a.OptionalLiveReloadServer : LiveReload server is running on port 35729@b@2022-11-19 01:16:26.168 INFO 10928 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8081 (http) with context path ''@b@2022-11-19 01:16:26.183 INFO 10928 --- [ restartedMain] c.j.a.AutoGeneratorApplication : Started AutoGeneratorApplication in 5.773 seconds (JVM running for 9.832)@b@2022-11-19 01:19:23.914 INFO 10928 --- [nio-8081-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring DispatcherServlet 'dispatcherServlet'@b@2022-11-19 01:19:23.915 INFO 10928 --- [nio-8081-exec-1] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet'@b@2022-11-19 01:19:23.917 INFO 10928 --- [nio-8081-exec-1] o.s.web.servlet.DispatcherServlet : Completed initialization in 2 ms@b@2022-11-19 01:19:29.077 INFO 10928 --- [nio-8081-exec-5] com.alibaba.druid.pool.DruidDataSource : {dataSource-1} inited
2)浏览器访问http://localhost:8081/ ,如下图,勾选需要生成表,点击“生成代码”按钮(生成目标代码下载查看 - 链接:https://pan.baidu.com/s/1vqIJ02hC8HE1gJeSvsuz6g?pwd=pc5k 提取码:pc5k)