Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ddc327273d | |||
| af972d2c14 | |||
| 05133a7e40 | |||
| 3463a6109e | |||
| 1b2355b60c |
5
template/.gitignore
vendored
5
template/.gitignore
vendored
@@ -10,9 +10,10 @@ classes/
|
|||||||
|
|
||||||
## idea
|
## idea
|
||||||
*.iml
|
*.iml
|
||||||
.idea/**
|
.idea/*
|
||||||
HELP.md
|
!.idea/codeStyles/
|
||||||
!.idea/dataSources.xml
|
!.idea/dataSources.xml
|
||||||
|
HELP.md
|
||||||
|
|
||||||
## vscode
|
## vscode
|
||||||
.vscode/
|
.vscode/
|
||||||
|
|||||||
@@ -1,20 +1,42 @@
|
|||||||
package com.vs;
|
package com.vs;
|
||||||
|
|
||||||
import com.vs.common.util.rpc.handler.CustomArgumentResolver;
|
import com.vs.common.util.rpc.handler.CustomArgumentResolver;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.web.method.annotation.MapMethodProcessor;
|
||||||
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
|
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
|
||||||
import org.springframework.web.method.support.HandlerMethodReturnValueHandler;
|
import org.springframework.web.method.support.HandlerMethodReturnValueHandler;
|
||||||
import org.springframework.web.servlet.HandlerExceptionResolver;
|
import org.springframework.web.servlet.HandlerExceptionResolver;
|
||||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||||
|
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter;
|
||||||
|
import org.springframework.web.servlet.mvc.method.annotation.ViewNameMethodReturnValueHandler;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
public class VSResponseHandlerConfig implements WebMvcConfigurer {
|
public class VSResponseHandlerConfig implements WebMvcConfigurer {
|
||||||
|
|
||||||
@Value("${com.toco.response.handler:true}")
|
private boolean useHandler = true;
|
||||||
private boolean useHandler;
|
RequestMappingHandlerAdapter requestMappingHandlerAdapter;
|
||||||
|
|
||||||
|
void init() {
|
||||||
|
List<HandlerMethodReturnValueHandler> returnValueHandlers = this.requestMappingHandlerAdapter.getReturnValueHandlers();
|
||||||
|
Iterator<HandlerMethodReturnValueHandler> iterator = returnValueHandlers.iterator();
|
||||||
|
List<HandlerMethodReturnValueHandler> newProcessors = new ArrayList<>();
|
||||||
|
while (iterator.hasNext()) {
|
||||||
|
HandlerMethodReturnValueHandler next = iterator.next();
|
||||||
|
//在controller中直接返回map,不被默认的MapMethodProcessor拦截
|
||||||
|
if (next instanceof MapMethodProcessor ||
|
||||||
|
//在controller中直接返回String,不被默认的ViewNameMethodReturnValueHandler拦截
|
||||||
|
next instanceof ViewNameMethodReturnValueHandler) {
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
newProcessors.add(next);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.requestMappingHandlerAdapter.setReturnValueHandlers(newProcessors);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> resolvers) {
|
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> resolvers) {
|
||||||
|
|||||||
@@ -126,3 +126,4 @@ essql.scheme={{ .elasticsearch_scheme }}
|
|||||||
|
|
||||||
base.package=com.insigma;{{.groupId}}
|
base.package=com.insigma;{{.groupId}}
|
||||||
cross.domain.headers=application-id
|
cross.domain.headers=application-id
|
||||||
|
spring.devtools.restart.exclude={{.packagePath}}/**
|
||||||
@@ -624,6 +624,23 @@
|
|||||||
</execution>-->
|
</execution>-->
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>com.diffplug.spotless</groupId>
|
||||||
|
<artifactId>spotless-maven-plugin</artifactId>
|
||||||
|
<version>2.43.0</version>
|
||||||
|
<configuration>
|
||||||
|
<java>
|
||||||
|
<googleJavaFormat>
|
||||||
|
<groupArtifact>com.google.googlejavaformat:google-java-format</groupArtifact>
|
||||||
|
<version>1.22.0</version>
|
||||||
|
<style>AOSP</style>
|
||||||
|
<reorderImports>true</reorderImports>
|
||||||
|
<reflowLongStrings>true</reflowLongStrings>
|
||||||
|
<formatJavadoc>true</formatJavadoc>
|
||||||
|
</googleJavaFormat>
|
||||||
|
</java>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
<repositories>
|
<repositories>
|
||||||
|
|||||||
Reference in New Issue
Block a user