Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit d04f479

Browse files
| 2024年04月22日 | [Java CI with Maven](https://github.com/moshowgame/SpringBootCodeGenerator/actions/workflows/maven.yml) 更新<br>SpringBoot升级到3.2.5<br>FastJSON升级到FastJSON2.0.49|
| 2024年04月22日 | [Java CI with Maven](https://github.com/moshowgame/SpringBootCodeGenerator/actions/workflows/maven.yml) 更新<br>SpringBoot升级到3.2.5<br>FastJSON升级到FastJSON2.0.49|
1 parent 303d1ee commit d04f479

File tree

5 files changed

+93
-36
lines changed

5 files changed

+93
-36
lines changed

‎README.md

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
![image](https://img.shields.io/badge/SpringBoot2-%E2%98%85%E2%98%85%E2%98%85%E2%98%85%E2%98%85-blue.svg)
55
![image](https://img.shields.io/badge/Freemarker-%E2%98%85%E2%98%85%E2%98%85%E2%98%85%E2%98%85-blue.svg)
66
![image](https://img.shields.io/badge/CodeGenerator-%E2%98%85%E2%98%85%E2%98%85%E2%98%85%E2%98%85-blue.svg)
7-
[![Build Status](https://travis-ci.org/moshowgame/SpringBootCodeGenerator.svg?branch=master)](https://travis-ci.org/moshowgame/SpringBootCodeGenerator)
7+
[![Java CI with Maven](https://github.com/moshowgame/SpringBootCodeGenerator/actions/workflows/maven.yml/badge.svg)](https://github.com/moshowgame/SpringBootCodeGenerator/actions/workflows/maven.yml)
88

99
# Author
1010
>powered by `Moshow郑锴(大狼狗)` , [https://zhengkai.blog.csdn.net](https://zhengkai.blog.csdn.net)
@@ -73,10 +73,10 @@
7373
# Update Logs
7474
| 更新日期 | 更新内容 |
7575
|:-----------|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
76-
| 2024.04.21 | 推出JDK11分支,支持JDK8/JDK11/JDK17等版本,兼容性较好但维护速度较慢,为了更好兼容旧机器和旧环境
77-
| 2024.04.20 | 修复CDN版本cdn.staticfile.org域名备份失败问题,已同步更新到cdn.staticfile.net(本地版本则不受影响)
78-
| 2024.01.26 | 修复大写下滑线列名转驼峰问题(感谢@Nisus-Liu
79-
的PR) |
76+
| 2024.04.22 | [Java CI with Maven](https://github.com/moshowgame/SpringBootCodeGenerator/actions/workflows/maven.yml) 更新<br>SpringBoot升级到3.2.5<br>FastJSON升级到FastJSON2.0.49|
77+
| 2024.04.21 | 推出JDK11分支,支持JDK8/JDK11/JDK17等版本,兼容性较好但维护速度较慢,为了更好兼容旧机器和旧环境|
78+
| 2024.04.20 | 修复CDN版本cdn.staticfile.org域名备份失败问题,已同步更新到cdn.staticfile.net(本地版本则不受影响)|
79+
| 2024年01月26日 | 修复大写下滑线列名转驼峰问题(感谢@Nisus-Liu的PR)|
8080
| 2023年10月22日 | 工具站CDN更新。 |
8181
| 2023年08月31日 | (感谢@Nisus-Liu的PR)<br>fix 驼峰列名转命名风格错误问题<br>增强转下划线命名风格, 对原始风格不敏感. 支持各种命名风格的列名 to 下划线<br>增加 NonCaseString 大小写不敏感字符串包装类, 简化编码<br>几点代码小优化。 |
8282
| 2023年07月11日 | 安全更新,正式支持SpringBoot3,javax升级到jakarta。 |
@@ -174,6 +174,13 @@
174174
2. COPY并编写freemarker模板文件`.ftl`
175175
3. 修改`template.json`文件,新增模板信息,页面可动态加载
176176

177+
# Upgrade Issue Resolution 升级问题解决方案
178+
- 如果你最近也在升级FastJson到FastJson2版本,而跟我一样也遇到了FastJsonHttpMessageConverter找不到类问题以及FastJsonConfig找不到问题,那么恭喜你,看完本文,安装完fastjson2、fastjson2-extension、fastjson2-extension-spring6这三个类库,你就可以成功使用新版FastJson2了。
179+
[FastJson2中FastJsonHttpMessageConverter找不到类问题](https://blog.csdn.net/moshowgame/article/details/138013669)
180+
181+
- 当项目从2.7.x的springboot升级到3.0.x的时候,遇到一个问题"java: 程序包javax.servlet.http不存在" 问题:
182+
[java: 程序包javax.servlet.http不存在](https://zhengkai.blog.csdn.net/article/details/131362304)
183+
177184
<img src="./codegenerator1.png">
178185
<img src="./codegenerator2.png">
179186
<img src="./site_analysis-2024.png">
Lines changed: 44 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
package com.softdev.system.generator.config;
22

3-
import com.alibaba.fastjson.support.config.FastJsonConfig;
4-
import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter;
3+
4+
// import com.alibaba.fastjson.support.config.FastJsonConfig;
5+
// import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter;
56
import jakarta.servlet.DispatcherType;
67
import org.springframework.boot.web.servlet.FilterRegistrationBean;
78
import org.springframework.context.annotation.Bean;
@@ -12,8 +13,14 @@
1213
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
1314
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
1415

16+
import com.alibaba.fastjson2.JSONReader;
17+
import com.alibaba.fastjson2.JSONWriter;
18+
import com.alibaba.fastjson2.support.config.FastJsonConfig;
19+
import com.alibaba.fastjson2.support.spring6.http.converter.FastJsonHttpMessageConverter;
20+
1521
import java.nio.charset.StandardCharsets;
1622
import java.util.ArrayList;
23+
import java.util.Collections;
1724
import java.util.List;
1825
/**
1926
* 2019年2月11日 liutf WebMvcConfig 整合 cors 和 SpringMvc MessageConverter
@@ -36,25 +43,43 @@ public FilterRegistrationBean xssFilterRegistration() {
3643
return registration;
3744
}
3845

46+
// @Override
47+
// public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
48+
// converters.clear();
49+
// //FastJsonHttpMessageConverter
50+
// FastJsonHttpMessageConverter fastConverter = new FastJsonHttpMessageConverter();
51+
52+
// List<MediaType> fastMediaTypes = new ArrayList<>();
53+
// fastMediaTypes.add(MediaType.APPLICATION_JSON_UTF8);
54+
// fastConverter.setSupportedMediaTypes(fastMediaTypes);
55+
56+
// FastJsonConfig fastJsonConfig = new FastJsonConfig();
57+
// fastJsonConfig.setCharset(StandardCharsets.UTF_8);
58+
// fastConverter.setFastJsonConfig(fastJsonConfig);
59+
60+
// //StringHttpMessageConverter
61+
// StringHttpMessageConverter stringConverter = new StringHttpMessageConverter();
62+
// stringConverter.setDefaultCharset(StandardCharsets.UTF_8);
63+
// stringConverter.setSupportedMediaTypes(fastMediaTypes);
64+
// converters.add(stringConverter);
65+
// converters.add(fastConverter);
66+
// }
67+
/**
68+
* FASTJSON2升级 by https://zhengkai.blog.csdn.net/
69+
* https://blog.csdn.net/moshowgame/article/details/138013669
70+
*/
3971
@Override
4072
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
41-
//FastJsonHttpMessageConverter
42-
FastJsonHttpMessageConverter fastConverter = new FastJsonHttpMessageConverter();
43-
44-
List<MediaType> fastMediaTypes = new ArrayList<>();
45-
fastMediaTypes.add(MediaType.APPLICATION_JSON_UTF8);
46-
fastConverter.setSupportedMediaTypes(fastMediaTypes);
47-
48-
FastJsonConfig fastJsonConfig = new FastJsonConfig();
49-
fastJsonConfig.setCharset(StandardCharsets.UTF_8);
50-
fastConverter.setFastJsonConfig(fastJsonConfig);
51-
52-
//StringHttpMessageConverter
53-
StringHttpMessageConverter stringConverter = new StringHttpMessageConverter();
54-
stringConverter.setDefaultCharset(StandardCharsets.UTF_8);
55-
stringConverter.setSupportedMediaTypes(fastMediaTypes);
56-
converters.add(stringConverter);
57-
converters.add(fastConverter);
73+
FastJsonHttpMessageConverter converter = new FastJsonHttpMessageConverter();
74+
//自定义配置...
75+
FastJsonConfig config = new FastJsonConfig();
76+
config.setDateFormat("yyyy-MM-dd HH:mm:ss");
77+
config.setReaderFeatures(JSONReader.Feature.FieldBased, JSONReader.Feature.SupportArrayToBean);
78+
config.setWriterFeatures(JSONWriter.Feature.WriteMapNullValue, JSONWriter.Feature.PrettyFormat);
79+
converter.setFastJsonConfig(config);
80+
converter.setDefaultCharset(StandardCharsets.UTF_8);
81+
converter.setSupportedMediaTypes(Collections.singletonList(MediaType.APPLICATION_JSON));
82+
converters.add(0, converter);
5883
}
5984

6085
}

‎generator-web/src/main/java/com/softdev/system/generator/service/GeneratorServiceImpl.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package com.softdev.system.generator.service;
22

3-
import com.alibaba.fastjson.JSON;
4-
import com.alibaba.fastjson.JSONArray;
5-
import com.alibaba.fastjson.JSONObject;
3+
import com.alibaba.fastjson2.JSON;
4+
import com.alibaba.fastjson2.JSONArray;
5+
import com.alibaba.fastjson2.JSONObject;
66
import com.softdev.system.generator.entity.TemplateConfig;
77
import com.softdev.system.generator.util.FreemarkerUtil;
88
import com.softdev.system.generator.util.MapUtil;

‎generator-web/src/main/java/com/softdev/system/generator/util/TableParseUtil.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package com.softdev.system.generator.util;
22

3-
import com.alibaba.fastjson.JSON;
4-
import com.alibaba.fastjson.JSONArray;
5-
import com.alibaba.fastjson.JSONObject;
3+
import com.alibaba.fastjson2.JSON;
4+
import com.alibaba.fastjson2.JSONArray;
5+
import com.alibaba.fastjson2.JSONObject;
66
import com.softdev.system.generator.entity.ClassInfo;
77
import com.softdev.system.generator.entity.FieldInfo;
88
import com.softdev.system.generator.entity.NonCaseString;

‎pom.xml

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<parent>
1212
<groupId>org.springframework.boot</groupId>
1313
<artifactId>spring-boot-starter-parent</artifactId>
14-
<version>3.0.8</version>
14+
<version>3.2.5</version>
1515
</parent>
1616

1717
<modules>
@@ -46,10 +46,28 @@
4646
</dependency>
4747

4848
<!-- https://mvnrepository.com/artifact/com.alibaba/fastjson -->
49-
<dependency>
49+
<!-- <dependency>
5050
<groupId>com.alibaba</groupId>
5151
<artifactId>fastjson</artifactId>
5252
<version>2.0.34</version>
53+
</dependency> -->
54+
<!-- FastJson2中FastJsonHttpMessageConverter找不到类问题 by https://zhengkai.blog.csdn.net/-->
55+
<!-- https://mvnrepository.com/artifact/com.alibaba.fastjson2/fastjson2 -->
56+
<dependency>
57+
<groupId>com.alibaba.fastjson2</groupId>
58+
<artifactId>fastjson2</artifactId>
59+
<version>2.0.49</version>
60+
</dependency>
61+
<dependency>
62+
<groupId>com.alibaba.fastjson2</groupId>
63+
<artifactId>fastjson2-extension</artifactId>
64+
<version>2.0.49</version>
65+
</dependency>
66+
<!-- https://mvnrepository.com/artifact/com.alibaba.fastjson2/fastjson2-extension-spring6 -->
67+
<dependency>
68+
<groupId>com.alibaba.fastjson2</groupId>
69+
<artifactId>fastjson2-extension-spring6</artifactId>
70+
<version>2.0.49</version>
5371
</dependency>
5472

5573
<!-- https://mvnrepository.com/artifact/jakarta.servlet/jakarta.servlet-api -->
@@ -85,7 +103,7 @@
85103
<dependency>
86104
<groupId>org.projectlombok</groupId>
87105
<artifactId>lombok</artifactId>
88-
<version>1.18.22</version>
106+
<version>1.18.32</version>
89107
</dependency>
90108

91109
<!-- freemarker -->
@@ -95,23 +113,30 @@
95113
</dependency>
96114
<!--server issue-->
97115
<!-- https://mvnrepository.com/artifact/javax.xml.bind/jaxb-api -->
98-
<dependency>
116+
<!-- <dependency>
99117
<groupId>javax.xml.bind</groupId>
100118
<artifactId>jaxb-api</artifactId>
101119
<version>2.3.1</version>
120+
</dependency> -->
121+
<!-- https://mvnrepository.com/artifact/jakarta.xml.bind/jakarta.xml.bind-api -->
122+
<dependency>
123+
<groupId>jakarta.xml.bind</groupId>
124+
<artifactId>jakarta.xml.bind-api</artifactId>
125+
<version>4.0.2</version>
102126
</dependency>
103127

128+
104129
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 -->
105130
<dependency>
106131
<groupId>org.apache.commons</groupId>
107132
<artifactId>commons-lang3</artifactId>
108-
<version>3.12.0</version>
133+
<version>3.14.0</version>
109134
</dependency>
110135
<!-- https://mvnrepository.com/artifact/commons-io/commons-io -->
111136
<dependency>
112137
<groupId>commons-io</groupId>
113138
<artifactId>commons-io</artifactId>
114-
<version>2.11.0</version>
139+
<version>2.16.1</version>
115140
</dependency>
116141

117142
</dependencies>

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /