├── .gitignore
├── .travis.yml
├── README.md
├── SpringBootCodeGenerator.iml
├── app.sh
├── codegenerator1.png
├── codegenerator2.png
├── codegenerator3.png
├── codegenerator4.png
├── donate.jpg
├── generator-web
├── generator-web.iml
├── pom.xml
└── src
│ └── main
│ ├── java
│ └── com
│ │ └── softdev
│ │ └── system
│ │ └── generator
│ │ ├── GeneratorWebApplication.java
│ │ ├── config
│ │ ├── GlobalDefaultExceptionHandler.java
│ │ ├── ServerConfig.java
│ │ └── WebMvcConfig.java
│ │ ├── controller
│ │ └── IndexController.java
│ │ ├── entity
│ │ ├── ClassInfo.java
│ │ ├── FieldInfo.java
│ │ └── ReturnT.java
│ │ └── util
│ │ ├── ApiReturnObject.java
│ │ ├── ApiReturnUtil.java
│ │ ├── BasePath.java
│ │ ├── CodeGenerateException.java
│ │ ├── CodeGeneratorTool.java
│ │ ├── FreemarkerTool.java
│ │ ├── FreemarkerUtil.java
│ │ ├── StringPlusUtils.java
│ │ ├── StringUtils.java
│ │ └── TableParseUtil.java
│ └── resources
│ ├── application.yml
│ ├── favicon.ico
│ └── templates
│ ├── code-generator
│ ├── beetlsql
│ │ ├── beetlcontroller.ftl
│ │ ├── beetlentity.ftl
│ │ ├── beetlentitydto.ftl
│ │ └── beetlmd.ftl
│ ├── jdbc-template
│ │ ├── jtdao.ftl
│ │ └── jtdaoimpl.ftl
│ ├── jpa-new
│ │ ├── dto.ftl
│ │ ├── entity.ftl
│ │ ├── jpacontroller-old.ftl
│ │ ├── jpacontroller.ftl
│ │ ├── repository.ftl
│ │ ├── service.ftl
│ │ └── vo.ftl
│ ├── jpa-rest-delete
│ │ ├── dto.ftl
│ │ ├── entity.ftl
│ │ ├── jpacontroller-old.ftl
│ │ ├── jpacontroller.ftl
│ │ ├── repository.ftl
│ │ ├── service.ftl
│ │ └── vo.ftl
│ ├── jpa-rest
│ │ ├── addparam.ftl
│ │ ├── dto.ftl
│ │ ├── entity.ftl
│ │ ├── jpacontroller-old.ftl
│ │ ├── jpacontroller.ftl
│ │ ├── pageparam.ftl
│ │ ├── projection.ftl
│ │ ├── repository.ftl
│ │ ├── service.ftl
│ │ ├── test.ftl
│ │ ├── updateparam.ftl
│ │ └── vo.ftl
│ ├── jpa
│ │ ├── entity.ftl
│ │ ├── jpacontroller.ftl
│ │ └── repository.ftl
│ ├── mybatis-plus
│ │ ├── pluscontroller.ftl
│ │ └── plusmapper.ftl
│ ├── mybatis
│ │ ├── controller.ftl
│ │ ├── mapper.ftl
│ │ ├── model.ftl
│ │ ├── mybatis.ftl
│ │ ├── service.ftl
│ │ └── service_impl.ftl
│ ├── restful-jpa
│ │ ├── entity.ftl
│ │ ├── jpacontroller.ftl
│ │ ├── repository.ftl
│ │ └── service.ftl
│ ├── ui
│ │ ├── bootstrap-ui.ftl
│ │ ├── element-ui.ftl
│ │ └── swagger-ui.ftl
│ └── util
│ │ └── util.ftl
│ ├── common
│ └── common-import.ftl
│ ├── index.ftl
│ └── sql-generator
│ └── pgsql
│ ├── delete.ftl
│ ├── drop.ftl
│ ├── insert.ftl
│ ├── select.ftl
│ ├── sql.ftl
│ └── update.ftl
└── pom.xml
/.gitignore:
--------------------------------------------------------------------------------
1 |
2 | # Created by https://www.gitignore.io/api/java,maven,eclipse,java-web,intellij+all
3 | # Edit at https://www.gitignore.io/?templates=java,maven,eclipse,java-web,intellij+all
4 |
5 | ### Eclipse ###
6 | .metadata
7 | bin/
8 | tmp/
9 | *.tmp
10 | *.bak
11 | *.swp
12 | *~.nib
13 | local.properties
14 | .settings/
15 | .loadpath
16 | .recommenders
17 |
18 | # External tool builders
19 | .externalToolBuilders/
20 |
21 | # Locally stored "Eclipse launch configurations"
22 | *.launch
23 |
24 | # PyDev specific (Python IDE for Eclipse)
25 | *.pydevproject
26 |
27 | # CDT-specific (C/C++ Development Tooling)
28 | .cproject
29 |
30 | # CDT- autotools
31 | .autotools
32 |
33 | # Java annotation processor (APT)
34 | .factorypath
35 |
36 | # PDT-specific (PHP Development Tools)
37 | .buildpath
38 |
39 | # sbteclipse plugin
40 | .target
41 |
42 | # Tern plugin
43 | .tern-project
44 |
45 | # TeXlipse plugin
46 | .texlipse
47 |
48 | # STS (Spring Tool Suite)
49 | .springBeans
50 |
51 | # Code Recommenders
52 | .recommenders/
53 |
54 | # Annotation Processing
55 | .apt_generated/
56 |
57 | # Scala IDE specific (Scala & Java development for Eclipse)
58 | .cache-main
59 | .scala_dependencies
60 | .worksheet
61 |
62 | ### Eclipse Patch ###
63 | # Eclipse Core
64 | .project
65 |
66 | # JDT-specific (Eclipse Java Development Tools)
67 | .classpath
68 |
69 | # Annotation Processing
70 | .apt_generated
71 |
72 | .sts4-cache/
73 |
74 | ### Intellij+all ###
75 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
76 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
77 |
78 | # User-specific stuff
79 | .idea/**/workspace.xml
80 | .idea/**/tasks.xml
81 | .idea/**/usage.statistics.xml
82 | .idea/**/dictionaries
83 | .idea/**/shelf
84 |
85 | # Generated files
86 | .idea/**/contentModel.xml
87 |
88 | # Sensitive or high-churn files
89 | .idea/**/dataSources/
90 | .idea/**/dataSources.ids
91 | .idea/**/dataSources.local.xml
92 | .idea/**/sqlDataSources.xml
93 | .idea/**/dynamic.xml
94 | .idea/**/uiDesigner.xml
95 | .idea/**/dbnavigator.xml
96 |
97 | # Gradle
98 | .idea/**/gradle.xml
99 | .idea/**/libraries
100 |
101 | # Gradle and Maven with auto-import
102 | # When using Gradle or Maven with auto-import, you should exclude module files,
103 | # since they will be recreated, and may cause churn. Uncomment if using
104 | # auto-import.
105 | # .idea/modules.xml
106 | # .idea/*.iml
107 | # .idea/modules
108 |
109 | # CMake
110 | cmake-build-*/
111 |
112 | # Mongo Explorer plugin
113 | .idea/**/mongoSettings.xml
114 |
115 | # File-based project format
116 | *.iws
117 |
118 | # IntelliJ
119 | out/
120 |
121 | # mpeltonen/sbt-idea plugin
122 | .idea_modules/
123 |
124 | # JIRA plugin
125 | atlassian-ide-plugin.xml
126 |
127 | # Cursive Clojure plugin
128 | .idea/replstate.xml
129 |
130 | # Crashlytics plugin (for Android Studio and IntelliJ)
131 | com_crashlytics_export_strings.xml
132 | crashlytics.properties
133 | crashlytics-build.properties
134 | fabric.properties
135 |
136 | # Editor-based Rest Client
137 | .idea/httpRequests
138 |
139 | # Android studio 3.1+ serialized cache file
140 | .idea/caches/build_file_checksums.ser
141 |
142 | # JetBrains templates
143 | **___jb_tmp___
144 |
145 | ### Intellij+all Patch ###
146 | # Ignores the whole .idea folder and all .iml files
147 | # See https://github.com/joeblau/gitignore.io/issues/186 and https://github.com/joeblau/gitignore.io/issues/360
148 |
149 | .idea/
150 |
151 | # Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-249601023
152 |
153 | *.iml
154 | modules.xml
155 | .idea/misc.xml
156 | *.ipr
157 |
158 | # Sonarlint plugin
159 | .idea/sonarlint
160 |
161 | ### Java ###
162 | # Compiled class file
163 | *.class
164 |
165 | # Log file
166 | *.log
167 |
168 | # BlueJ files
169 | *.ctxt
170 |
171 | # Mobile Tools for Java (J2ME)
172 | .mtj.tmp/
173 |
174 | # Package Files #
175 | *.jar
176 | *.war
177 | *.nar
178 | *.ear
179 | *.zip
180 | *.tar.gz
181 | *.rar
182 |
183 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
184 | hs_err_pid*
185 |
186 | ### Java-Web ###
187 | ## ignoring target file
188 | target/
189 |
190 | ### Maven ###
191 | pom.xml.tag
192 | pom.xml.releaseBackup
193 | pom.xml.versionsBackup
194 | pom.xml.next
195 | release.properties
196 | dependency-reduced-pom.xml
197 | buildNumber.properties
198 | .mvn/timing.properties
199 | .mvn/wrapper/maven-wrapper.jar
200 |
201 | # End of https://www.gitignore.io/api/java,maven,eclipse,java-web,intellij+all
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: java
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # SpringBootCodeGenerator
2 |
3 | 
4 | 
5 | 
6 | [](https://travis-ci.org/moshowgame/SpringBootCodeGenerator)
7 |
8 | > 原项目地址 [SpringBootCodeGenerator](https://github.com/moshowgame/SpringBootCodeGenerator)
9 | > 在此基础上进行了一些修改
10 |
11 | ### 项目介绍
12 |
13 | 基于SpringBoot2+Freemarker的代码生成器,用DDL SQL语句生成JPA/JdbcTemplate/Mybatis/BeetlSQL相关代码,支持mysql/oracle/pgsql等三大数据库。以释放双手为目的。
14 |
15 |
16 | 访问路径 | http://127.0.0.1:1234/generator |
17 | 在线地址 | http://java.bejson.com/generator |
18 |
19 |
20 |
21 | 字段名 | 说明 |
22 | packageName | 自定义的包名 |
23 | authorName | 自定义的作者名 |
24 | returnUtil | 自定义的返回Util |
25 | tableName | sql中的表名 |
26 | className | java类名 |
27 | classComment | sql表备注/java类备注 |
28 | fieldName | 字段名 |
29 | fieldComment | 字段备注 |
30 |
31 |
32 | ### 运行效果
33 |
34 | **首页**
35 |
36 | 
37 |
38 | ### 添加功能
39 |
40 | #### JPA-NEW(将JPA修改为适合自己项目的模板)
41 |
42 | 
43 |
44 | #### jpa rest (2019-8-27)
45 |
46 | 
47 |
48 | #### bean get set
49 |
50 | 项目中经常会遇到需要 get bean 所有属性和 set bean 所有属性的情况,添加此功能方便开发
51 |
52 | 
53 |
54 | #### SQL
55 |
56 | 使用Navicat 通常需要写select、insert、update、delete语句,比较麻烦,使用此功能只需要填充数据即可使用
57 |
58 | 
59 |
60 | 
61 |
62 | 
63 |
64 | 
65 |
66 |
67 |
68 |
69 |
70 |
71 |
--------------------------------------------------------------------------------
/SpringBootCodeGenerator.iml:
--------------------------------------------------------------------------------
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 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
--------------------------------------------------------------------------------
/app.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | ## blog:www.cnbuilder.cn
3 | ## create 2019-04-30
4 | version="5.2.1";
5 | appName=$2
6 | if [ -z $appName ];then
7 | appName=`ls -t |grep .jar$ |head -n1`
8 | fi
9 | ## 后台启动项目 自动生成 catalina.log日志文件
10 | function start()
11 | {
12 | count=`ps -ef |grep java|grep $appName|wc -l`
13 | if [ $count != 0 ];then
14 | echo "Maybe $appName is running, please check it..."
15 | else
16 | echo "The $appName is starting..."
17 | ulimit -c unlimited
18 | nohup java -jar ./$appName -XX:+UseG1GC -XX:+HeapDumpOnOutOfMemoryError -Xms512M -Xmx4G > catalina.log 2>&1 &
19 | fi
20 | }
21 | ## 停止项目
22 | function stop()
23 | {
24 | appId=`ps -ef |grep java|grep $appName|awk '{print $2}'`
25 | if [ -z $appId ];then
26 | echo "Maybe $appName not running, please check it..."
27 | else
28 | echo "The $appName is stopping..."
29 | kill -9 $appId
30 | fi
31 | }
32 | ##重启项目(平滑启动)
33 | function restart()
34 | {
35 | # get release version
36 | releaseApp=`ls -t |grep .jar$ |head -n1`
37 | # get last version
38 | lastVersionApp=`ls -t |grep .jar$ |head -n2 |tail -n1`
39 | appName=$lastVersionApp
40 | stop
41 | for i in {5..1}
42 | do
43 | echo -n "$i "
44 | sleep 1
45 | done
46 | echo 0
47 | backup
48 | appName=$releaseApp
49 | start
50 | }
51 | function backup()
52 | {
53 | # get backup version
54 | backupApp=`ls |grep -wv $releaseApp$ |grep .jar$`
55 | # create backup dir
56 | if [ ! -d "backup" ];then
57 | mkdir backup
58 | fi
59 | # backup
60 | for i in ${backupApp[@]}
61 | do
62 | echo "backup" $i
63 | mv $i backup
64 | done
65 | }
66 | ## 查看项目当前状态
67 | function status()
68 | {
69 | appId=`ps -ef |grep java|grep $appName|awk '{print $2}'`
70 | if [ -z $appId ]
71 | then
72 | echo -e "\033[31m Not running \033[0m"
73 | else
74 | echo -e "\033[32m Running [$appId] \033[0m"
75 | fi
76 | }
77 | function usage()
78 | {
79 | echo "Usage: $0 {start|stop|restart|status|stop -f}"
80 | echo "Example: $0 start"
81 | exit 1
82 | }
83 | case $1 in
84 | start)
85 | start;;
86 | stop)
87 | stop;;
88 | restart)
89 | restart;;
90 | status)
91 | status;;
92 | *)
93 | usage;;
94 | esac
95 |
--------------------------------------------------------------------------------
/codegenerator1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hacker-and-painter/spring-boot-code-generator/cad403fc56934b250da9be6afee59d3e70d06dcb/codegenerator1.png
--------------------------------------------------------------------------------
/codegenerator2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hacker-and-painter/spring-boot-code-generator/cad403fc56934b250da9be6afee59d3e70d06dcb/codegenerator2.png
--------------------------------------------------------------------------------
/codegenerator3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hacker-and-painter/spring-boot-code-generator/cad403fc56934b250da9be6afee59d3e70d06dcb/codegenerator3.png
--------------------------------------------------------------------------------
/codegenerator4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hacker-and-painter/spring-boot-code-generator/cad403fc56934b250da9be6afee59d3e70d06dcb/codegenerator4.png
--------------------------------------------------------------------------------
/donate.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hacker-and-painter/spring-boot-code-generator/cad403fc56934b250da9be6afee59d3e70d06dcb/donate.jpg
--------------------------------------------------------------------------------
/generator-web/generator-web.iml:
--------------------------------------------------------------------------------
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 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
--------------------------------------------------------------------------------
/generator-web/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 | 4.0.0
7 |
8 | com.softdev.system
9 | SpringBootCodeGenerator
10 | 0.0.1-SNAPSHOT
11 |
12 |
13 | com.softdev.system
14 | generator-web
15 | 0.0.1-SNAPSHOT
16 | jar
17 |
18 |
19 | UTF-8
20 | UTF-8
21 | 1.8
22 |
23 |
24 |
25 |
26 |
27 |
28 |
33 |
34 |
35 |
39 |
40 |
41 | junit
42 | junit
43 |
44 |
45 |
46 | com.spring4all
47 | swagger-spring-boot-starter
48 | 1.9.0.RELEASE
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 | src/main/java
59 |
60 | **/*.properties
61 | **/*.xml
62 |
63 | false
64 |
65 |
66 | src/main/resources
67 |
68 |
69 |
70 |
71 | org.apache.maven.plugins
72 | maven-compiler-plugin
73 | 3.1
74 |
75 | true
76 | javac
77 | 1.8
78 | 1.8
79 | UTF-8
80 | 1.8
81 | true
82 | true
83 |
84 |
85 |
86 | org.codehaus.plexus
87 | plexus-compiler-eclipse
88 | 2.2
89 |
90 |
91 |
92 |
93 | org.apache.maven.plugins
94 | maven-resources-plugin
95 | 3.0.1
96 |
97 |
98 | true
99 |
100 |
101 |
102 | org.apache.maven.plugins
103 | maven-war-plugin
104 | 2.1.1
105 |
106 | false
107 | upload/**
108 |
109 |
110 |
111 | org.springframework.boot
112 | spring-boot-maven-plugin
113 | 2.0.4.RELEASE
114 |
115 |
116 |
117 | repackage
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
--------------------------------------------------------------------------------
/generator-web/src/main/java/com/softdev/system/generator/GeneratorWebApplication.java:
--------------------------------------------------------------------------------
1 | package com.softdev.system.generator;
2 |
3 | import com.spring4all.swagger.EnableSwagger2Doc;
4 | import lombok.extern.slf4j.Slf4j;
5 | import org.springframework.boot.SpringApplication;
6 | import org.springframework.boot.autoconfigure.SpringBootApplication;
7 |
8 | @EnableSwagger2Doc
9 | @SpringBootApplication
10 | public class GeneratorWebApplication {
11 | public static void main(String[] args) {
12 | SpringApplication.run(GeneratorWebApplication.class,args);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/generator-web/src/main/java/com/softdev/system/generator/config/GlobalDefaultExceptionHandler.java:
--------------------------------------------------------------------------------
1 | package com.softdev.system.generator.config;
2 |
3 | import javax.servlet.http.HttpServletRequest;
4 |
5 | import org.springframework.web.bind.annotation.ControllerAdvice;
6 | import org.springframework.web.bind.annotation.ExceptionHandler;
7 | import org.springframework.web.bind.annotation.ResponseBody;
8 |
9 | import com.softdev.system.generator.util.ApiReturnObject;
10 | import com.softdev.system.generator.util.ApiReturnUtil;
11 |
12 | @ControllerAdvice
13 | public class GlobalDefaultExceptionHandler {
14 |
15 | @ExceptionHandler(Exception.class)
16 | @ResponseBody
17 | public ApiReturnObject defaultExceptionHandler(HttpServletRequest req,Exception e) {
18 | e.printStackTrace();
19 | return ApiReturnUtil.error("服务器异常",e.getMessage());
20 | }
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/generator-web/src/main/java/com/softdev/system/generator/config/ServerConfig.java:
--------------------------------------------------------------------------------
1 | package com.softdev.system.generator.config;
2 |
3 | import lombok.extern.slf4j.Slf4j;
4 | import org.springframework.boot.web.context.WebServerInitializedEvent;
5 | import org.springframework.context.ApplicationListener;
6 | import org.springframework.stereotype.Component;
7 | import java.net.Inet4Address;
8 | import java.net.InetAddress;
9 | import java.net.UnknownHostException;
10 |
11 | /**
12 | * @Description 通过实现ApplicationListener接口动态获取tomcat启动端口,再通过InetAddress类获取主机的ip地址,最后控制台打印项目访问地址
13 | * @Author Gao Hang Hang
14 | * @Date 2019-12-27 14:37
15 | **/
16 | @Component
17 | @Slf4j
18 | public class ServerConfig implements ApplicationListener {
19 |
20 | // tomcat启动端口
21 | private int serverPort;
22 |
23 | public int getPort() {
24 | return this.serverPort;
25 | }
26 |
27 | @Override
28 | public void onApplicationEvent(WebServerInitializedEvent event) {
29 | try {
30 | InetAddress inetAddress = Inet4Address.getLocalHost();
31 | this.serverPort = event.getWebServer().getPort();
32 | log.info("项目启动启动成功!访问地址: http://{}:{}", inetAddress.getHostAddress(), serverPort);
33 | } catch (UnknownHostException e) {
34 | e.printStackTrace();
35 | }
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/generator-web/src/main/java/com/softdev/system/generator/config/WebMvcConfig.java:
--------------------------------------------------------------------------------
1 | package com.softdev.system.generator.config;
2 |
3 | import com.alibaba.fastjson.support.config.FastJsonConfig;
4 | import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter;
5 | import org.springframework.context.annotation.Configuration;
6 | import org.springframework.http.MediaType;
7 | import org.springframework.http.converter.HttpMessageConverter;
8 | import org.springframework.http.converter.StringHttpMessageConverter;
9 | import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
10 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
11 |
12 | import java.nio.charset.Charset;
13 | import java.nio.charset.StandardCharsets;
14 | import java.util.ArrayList;
15 | import java.util.List;
16 |
17 | /**
18 | * 2019-2-11 liutf WebMvcConfig 整合 cors 和 SpringMvc MessageConverter
19 | */
20 | @Configuration
21 | public class WebMvcConfig implements WebMvcConfigurer {
22 |
23 | /* @Override
24 | public void addCorsMappings(CorsRegistry registry) {
25 | registry.addMapping("/**")
26 | .allowedOrigins("*")
27 | .allowedHeaders("x-requested-with")
28 | .allowedMethods("GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS", "TRACE")
29 | .maxAge(3600);
30 | }*/
31 |
32 | @Override
33 | public void configureMessageConverters(List> converters) {
34 | //FastJsonHttpMessageConverter
35 | FastJsonHttpMessageConverter fastConverter = new FastJsonHttpMessageConverter();
36 |
37 | List fastMediaTypes = new ArrayList<>();
38 | fastMediaTypes.add(MediaType.APPLICATION_JSON_UTF8);
39 | fastConverter.setSupportedMediaTypes(fastMediaTypes);
40 |
41 | FastJsonConfig fastJsonConfig = new FastJsonConfig();
42 | fastJsonConfig.setCharset(StandardCharsets.UTF_8);
43 | fastConverter.setFastJsonConfig(fastJsonConfig);
44 |
45 | //StringHttpMessageConverter
46 | StringHttpMessageConverter stringConverter = new StringHttpMessageConverter();
47 | stringConverter.setDefaultCharset(StandardCharsets.UTF_8);
48 | stringConverter.setSupportedMediaTypes(fastMediaTypes);
49 | converters.add(stringConverter);
50 | converters.add(fastConverter);
51 | }
52 |
53 | @Override
54 | public void addResourceHandlers(ResourceHandlerRegistry registry) {
55 | registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/");
56 | registry.addResourceHandler("swagger-ui.html")
57 | .addResourceLocations("classpath:/META-INF/resources/");
58 |
59 | registry.addResourceHandler("/webjars/**")
60 | .addResourceLocations("classpath:/META-INF/resources/webjars/");
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/generator-web/src/main/java/com/softdev/system/generator/controller/IndexController.java:
--------------------------------------------------------------------------------
1 | package com.softdev.system.generator.controller;
2 |
3 | import com.softdev.system.generator.entity.ClassInfo;
4 | import com.softdev.system.generator.entity.ReturnT;
5 | import com.softdev.system.generator.util.CodeGeneratorTool;
6 | import com.softdev.system.generator.util.FreemarkerTool;
7 | import freemarker.template.TemplateException;
8 | import io.swagger.annotations.ApiOperation;
9 | import lombok.extern.slf4j.Slf4j;
10 | import org.apache.commons.lang3.StringUtils;
11 | import org.springframework.beans.factory.annotation.Autowired;
12 | import org.springframework.stereotype.Controller;
13 | import org.springframework.web.bind.annotation.*;
14 | import java.io.IOException;
15 | import java.util.HashMap;
16 | import java.util.Map;
17 |
18 | /**
19 | * spring boot code generator
20 | *
21 | * @author zhengk/moshow
22 | */
23 | @Controller
24 | @Slf4j
25 | public class IndexController {
26 |
27 | @Autowired
28 | private FreemarkerTool freemarkerTool;
29 |
30 | @GetMapping("/")
31 | public String index() {
32 | return "index";
33 | }
34 |
35 | @PostMapping("/genCode")
36 | @ResponseBody
37 | public ReturnT