Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
guns-vip
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
chenjunxiong
guns-vip
Commits
6e647ca5
Commit
6e647ca5
authored
May 23, 2017
by
fsn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
springboot整合fastjson
parent
c85364d6
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
60 additions
and
5 deletions
+60
-5
pom.xml
+5
-5
src/main/java/com/stylefeng/guns/config/auto/FastjsonAutoConfiguration.java
+52
-0
src/main/resources/application.yml
+3
-0
No files found.
pom.xml
View file @
6e647ca5
...
...
@@ -72,11 +72,6 @@
<version>
1.7
</version>
</dependency>
<dependency>
<groupId>
com.alibaba
</groupId>
<artifactId>
fastjson
</artifactId>
<version>
${fastjson.version}
</version>
</dependency>
<dependency>
<groupId>
com.github.penggle
</groupId>
<artifactId>
kaptcha
</artifactId>
<version>
2.3.2
</version>
...
...
@@ -99,6 +94,11 @@
</dependency>
<dependency>
<groupId>
com.alibaba
</groupId>
<artifactId>
fastjson
</artifactId>
<version>
${fastjson.version}
</version>
</dependency>
<dependency>
<groupId>
com.alibaba
</groupId>
<artifactId>
druid
</artifactId>
<version>
1.0.31
</version>
</dependency>
...
...
src/main/java/com/stylefeng/guns/config/auto/FastjsonAutoConfiguration.java
0 → 100644
View file @
6e647ca5
package
com
.
stylefeng
.
guns
.
config
.
auto
;
import
com.alibaba.fastjson.serializer.SerializerFeature
;
import
com.alibaba.fastjson.serializer.ValueFilter
;
import
com.alibaba.fastjson.support.config.FastJsonConfig
;
import
com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter4
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnClass
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
/**
* fastjson自动配置类
*
* @author fengshuonan
* @date 2017-05-23 22:56
*/
@Configuration
@ConditionalOnClass
(
FastJsonHttpMessageConverter4
.
class
)
@ConditionalOnProperty
(
name
=
{
"spring.http.converters.preferred-json-mapper"
},
havingValue
=
"fastjson"
,
matchIfMissing
=
true
)
public
class
FastjsonAutoConfiguration
{
@Bean
@ConditionalOnMissingBean
(
FastJsonHttpMessageConverter4
.
class
)
public
FastJsonHttpMessageConverter4
fastJsonHttpMessageConverter
()
{
FastJsonHttpMessageConverter4
converter
=
new
FastJsonHttpMessageConverter4
();
FastJsonConfig
fastJsonConfig
=
new
FastJsonConfig
();
fastJsonConfig
.
setSerializerFeatures
(
SerializerFeature
.
PrettyFormat
,
SerializerFeature
.
WriteClassName
,
SerializerFeature
.
WriteMapNullValue
);
fastJsonConfig
.
setDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
ValueFilter
valueFilter
=
new
ValueFilter
()
{
public
Object
process
(
Object
o
,
String
s
,
Object
o1
)
{
if
(
null
==
o1
)
{
o1
=
""
;
}
return
o1
;
}
};
fastJsonConfig
.
setSerializeFilters
(
valueFilter
);
converter
.
setFastJsonConfig
(
fastJsonConfig
);
return
converter
;
}
}
src/main/resources/application.yml
View file @
6e647ca5
...
...
@@ -14,6 +14,9 @@ spring:
mvc
:
view
:
prefix
:
/WEB-INF/view
http
:
converters
:
preferred-json-mapper
:
fastjson
################### mybatis-plus配置 ###################
mybatis-plus
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment