Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
X
xyqb-user2
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
head_group
xyqb-user2
Commits
bd6fdd29
Commit
bd6fdd29
authored
Mar 30, 2018
by
技术部-任文超
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'convert'
parents
9ad3153e
d086ffb2
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
15 deletions
+33
-15
pom.xml
pom.xml
+0
-4
HttpConfig.java
src/main/java/cn/quantgroup/xyqb/config/http/HttpConfig.java
+17
-11
MyWebMvcConfigurer.java
...va/cn/quantgroup/xyqb/config/http/MyWebMvcConfigurer.java
+16
-0
No files found.
pom.xml
View file @
bd6fdd29
...
...
@@ -66,10 +66,6 @@
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-data-jpa
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-data-rest
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-integration
</artifactId>
...
...
src/main/java/cn/quantgroup/xyqb/config/http/HttpConfig.java
View file @
bd6fdd29
...
...
@@ -30,6 +30,8 @@ import org.springframework.boot.web.servlet.FilterRegistrationBean;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.core.convert.converter.ConverterRegistry
;
import
org.springframework.format.support.DefaultFormattingConversionService
;
import
org.springframework.format.support.FormattingConversionService
;
import
org.springframework.http.converter.json.Jackson2ObjectMapperBuilder
;
import
org.springframework.web.filter.CharacterEncodingFilter
;
...
...
@@ -78,20 +80,24 @@ public class HttpConfig {
return
builder
;
}
// hack spring mvc.
@Bean
public
IntegerToEnumConverterFactory
getIntegerToEnumConverterFactory
(
ConverterRegistry
defaultConversionService
,
ConverterRegistry
mvcConversionService
,
ConverterRegistry
integrationConversionService
)
{
IntegerToEnumConverterFactory
factory
=
new
IntegerToEnumConverterFactory
();
public
ConverterRegistry
defaultConversionService
()
{
FormattingConversionService
conversionService
=
new
DefaultFormattingConversionService
();
addFormatters
(
conversionService
);
return
conversionService
;
}
@Bean
public
ConverterRegistry
integrationConversionService
()
{
FormattingConversionService
conversionService
=
new
DefaultFormattingConversionService
();
addFormatters
(
conversionService
);
return
conversionService
;
}
defaultConversionService
.
removeConvertible
(
String
.
class
,
Enum
.
class
);
mvcConversionService
.
removeConvertible
(
String
.
class
,
Enum
.
class
);
integrationConversionService
.
removeConvertible
(
String
.
class
,
Enum
.
class
);
defaultConversionService
.
addConverterFactory
(
factory
);
mvcConversionService
.
addConverterFactory
(
factory
);
integrationConversionService
.
addConverterFactory
(
factory
);
return
factory
;
private
void
addFormatters
(
FormattingConversionService
conversionService
)
{
IntegerToEnumConverterFactory
factory
=
new
IntegerToEnumConverterFactory
(
);
conversionService
.
removeConvertible
(
String
.
class
,
Enum
.
class
);
conversionService
.
addConverterFactory
(
factory
)
;
}
@Bean
(
name
=
"httpClient"
)
...
...
src/main/java/cn/quantgroup/xyqb/config/http/MyWebMvcConfigurer.java
0 → 100644
View file @
bd6fdd29
package
cn
.
quantgroup
.
xyqb
.
config
.
http
;
import
org.springframework.format.FormatterRegistry
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
;
@Component
public
class
MyWebMvcConfigurer
extends
WebMvcConfigurerAdapter
{
@Override
public
void
addFormatters
(
FormatterRegistry
registry
)
{
registry
.
removeConvertible
(
String
.
class
,
Enum
.
class
);
registry
.
addConverterFactory
(
new
IntegerToEnumConverterFactory
());
}
}
\ No newline at end of file
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