【疑难杂症】org.springframework.context.ApplicationContextException: Failed to start bean 'documentationPluginsBootstrapper'; nested exception is com.google.common.util.concurrent.ExecutionError: java.lang.StackOverflowError

问题介绍

今天在给服务器写接口的时候,突然出现了这个栈溢出的情况。网上搜不到问题和解决办法。看日志好像是跟文档有关。百思不得其解。好在知道引起错误的代码范围,用了一个笨办法,一个方法一个方法去对照。所幸最终找到了报错的原因。

本文由作者三汪首发于简书。

错误日志

2017-08-04 14:43:44.451  INFO 12156 --- [restartedMain] com.qipai.MemberMsApplication            : Starting MemberMsApplication on XM77025331 with PID 12156 (D:\dev\qipaiDev\workspace\member-ms\target\classes started by 77025331 in D:\dev\qipaiDev\workspace\member-ms)
2017-08-04 14:43:44.452  INFO 12156 --- [restartedMain] com.qipai.MemberMsApplication            : No active profile set, falling back to default profiles: default
2017-08-04 14:43:44.507  INFO 12156 --- [restartedMain] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@25cd3a9a: startup date [Fri Aug 04 14:43:44 CST 2017]; root of context hierarchy
2017-08-04 14:43:46.044  WARN 12156 --- [restartedMain] o.m.s.mapper.ClassPathMapperScanner      : No MyBatis mapper was found in '[com.qipai]' package. Please check your configuration.
2017-08-04 14:43:46.686  INFO 12156 --- [restartedMain] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
2017-08-04 14:43:46.915  INFO 12156 --- [restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$d2ba77fd] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2017-08-04 14:43:47.082  INFO 12156 --- [restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'jsonConfig' of type [com.qipai.fw.config.JsonConfig$$EnhancerBySpringCGLIB$$e519a0d6] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2017-08-04 14:43:47.563  INFO 12156 --- [restartedMain] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)
2017-08-04 14:43:47.574  INFO 12156 --- [restartedMain] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2017-08-04 14:43:47.575  INFO 12156 --- [restartedMain] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.5.16
2017-08-04 14:43:47.715  INFO 12156 --- [localhost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2017-08-04 14:43:47.715  INFO 12156 --- [localhost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 3210 ms
2017-08-04 14:43:47.938  INFO 12156 --- [localhost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean  : Mapping servlet: 'dispatcherServlet' to [/]
2017-08-04 14:43:47.944  INFO 12156 --- [localhost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'characterEncodingFilter' to: [/*]
2017-08-04 14:43:47.945  INFO 12156 --- [localhost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2017-08-04 14:43:47.945  INFO 12156 --- [localhost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2017-08-04 14:43:47.945  INFO 12156 --- [localhost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'requestContextFilter' to: [/*]
2017-08-04 14:43:47.946  INFO 12156 --- [localhost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'webRequestParmFilter' to urls: [/*]
2017-08-04 14:43:47.946  INFO 12156 --- [localhost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'corsFilter' to: [/*]
2017-08-04 14:43:48.685  INFO 12156 --- [restartedMain] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default'
2017-08-04 14:43:48.701  INFO 12156 --- [restartedMain] o.hibernate.jpa.internal.util.LogHelper  : HHH000204: Processing PersistenceUnitInfo [
    name: default
    ...]
2017-08-04 14:43:48.788  INFO 12156 --- [restartedMain] org.hibernate.Version                    : HHH000412: Hibernate Core {5.0.12.Final}
2017-08-04 14:43:48.790  INFO 12156 --- [restartedMain] org.hibernate.cfg.Environment            : HHH000206: hibernate.properties not found
2017-08-04 14:43:48.792  INFO 12156 --- [restartedMain] org.hibernate.cfg.Environment            : HHH000021: Bytecode provider name : javassist
2017-08-04 14:43:48.842  INFO 12156 --- [restartedMain] o.hibernate.annotations.common.Version   : HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
2017-08-04 14:43:48.986  INFO 12156 --- [restartedMain] org.hibernate.dialect.Dialect            : HHH000400: Using dialect: org.hibernate.dialect.MySQL5Dialect
2017-08-04 14:43:49.265  WARN 12156 --- [restartedMain] org.hibernate.id.UUIDHexGenerator        : HHH000409: Using org.hibernate.id.UUIDHexGenerator which does not generate IETF RFC 4122 compliant UUID values; consider using org.hibernate.id.UUIDGenerator instead
2017-08-04 14:43:49.487  INFO 12156 --- [restartedMain] org.hibernate.tuple.PojoInstantiator     : HHH000182: No default (no-argument) constructor for class: com.qipai.member.api.shared.domain.WxDictDomain (class must be instantiated by Interceptor)
2017-08-04 14:43:49.628  INFO 12156 --- [restartedMain] org.hibernate.tool.hbm2ddl.SchemaUpdate  : HHH000228: Running hbm2ddl schema update
2017-08-04 14:43:50.010  INFO 12156 --- [restartedMain] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2017-08-04 14:43:53.215  INFO 12156 --- [restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/bonus_point/add],methods=[POST]}" onto public void com.qipai.member.server.web.BonusPointController.addBonusPointRecord(com.qipai.member.api.shared.vo.AddBonusPointsRecordVo)
2017-08-04 14:43:53.217  INFO 12156 --- [restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/bonus_point/get/{memberCode}],methods=[GET]}" onto public java.util.List<com.qipai.member.api.shared.domain.BonusPointDomain> com.qipai.member.server.web.BonusPointController.findByMemberCode(java.lang.String)
2017-08-04 14:43:53.222  INFO 12156 --- [restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/label/member/delete/{id}],methods=[DELETE]}" onto public void com.qipai.member.server.web.LabelController.deleteMemberLabel(java.lang.String)
2017-08-04 14:43:53.222  INFO 12156 --- [restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/label/member/add_fixed],methods=[POST]}" onto public void com.qipai.member.server.web.LabelController.addFixedMemberLabel(com.qipai.member.api.shared.domain.MemberLabelDomain)
2017-08-04 14:43:53.222  INFO 12156 --- [restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/label/member/add_personal],methods=[POST]}" onto public void com.qipai.member.server.web.LabelController.addPersonalMemberLabel(com.qipai.member.api.shared.domain.MemberDomain,com.qipai.member.api.shared.domain.LabelDictDomain)
2017-08-04 14:43:53.222  INFO 12156 --- [restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/label/member/get/{memberCode}],methods=[GET]}" onto public java.util.List<com.qipai.member.api.shared.domain.LabelDictDomain> com.qipai.member.server.web.LabelController.searchMemberLabel(java.lang.String)
2017-08-04 14:43:53.223  INFO 12156 --- [restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/label/dict/delete/{id}],methods=[DELETE]}" onto public void com.qipai.member.server.web.LabelController.deleteLabelDict(java.lang.String)
2017-08-04 14:43:53.223  INFO 12156 --- [restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/label/dict/add],methods=[POST]}" onto public void com.qipai.member.server.web.LabelController.addLabelDict(com.qipai.member.api.shared.domain.LabelDictDomain)
2017-08-04 14:43:53.223  INFO 12156 --- [restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/label/dict/search],methods=[GET]}" onto public java.util.List<com.qipai.member.api.shared.domain.LabelDictDomain> com.qipai.member.server.web.LabelController.searchLabelDict(java.lang.String,java.lang.String,java.lang.String)
2017-08-04 14:43:53.224  INFO 12156 --- [restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/member/searchMemberByVo],methods=[GET]}" onto public org.springframework.data.domain.Page<com.qipai.member.api.shared.domain.MemberDomain> com.qipai.member.server.web.MemberController.searchMemberByVo(com.qipai.member.api.shared.vo.MemberSearchVo,int,int)
2017-08-04 14:43:53.225  INFO 12156 --- [restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/v2/api-docs],methods=[GET],produces=[application/json || application/hal+json]}" onto public org.springframework.http.ResponseEntity<springfox.documentation.spring.web.json.Json> springfox.documentation.swagger2.web.Swagger2Controller.getDocumentation(java.lang.String,javax.servlet.http.HttpServletRequest)
2017-08-04 14:43:53.228  INFO 12156 --- [restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/swagger-resources/configuration/ui]}" onto org.springframework.http.ResponseEntity<springfox.documentation.swagger.web.UiConfiguration> springfox.documentation.swagger.web.ApiResourceController.uiConfiguration()
2017-08-04 14:43:53.229  INFO 12156 --- [restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/swagger-resources]}" onto org.springframework.http.ResponseEntity<java.util.List<springfox.documentation.swagger.web.SwaggerResource>> springfox.documentation.swagger.web.ApiResourceController.swaggerResources()
2017-08-04 14:43:53.230  INFO 12156 --- [restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/swagger-resources/configuration/security]}" onto org.springframework.http.ResponseEntity<springfox.documentation.swagger.web.SecurityConfiguration> springfox.documentation.swagger.web.ApiResourceController.securityConfiguration()
2017-08-04 14:43:53.233  INFO 12156 --- [restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2017-08-04 14:43:53.233  INFO 12156 --- [restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2017-08-04 14:43:53.634  INFO 12156 --- [restartedMain] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@25cd3a9a: startup date [Fri Aug 04 14:43:44 CST 2017]; root of context hierarchy
2017-08-04 14:43:53.693  INFO 12156 --- [restartedMain] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2017-08-04 14:43:53.694  INFO 12156 --- [restartedMain] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2017-08-04 14:43:53.715  INFO 12156 --- [restartedMain] .m.m.a.ExceptionHandlerExceptionResolver : Detected @ExceptionHandler methods in globalExceptionHandler
2017-08-04 14:43:53.743  INFO 12156 --- [restartedMain] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2017-08-04 14:43:54.188  INFO 12156 --- [restartedMain] o.s.b.d.a.OptionalLiveReloadServer       : LiveReload server is running on port 35729
2017-08-04 14:43:54.246  INFO 12156 --- [restartedMain] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
2017-08-04 14:43:54.255  INFO 12156 --- [restartedMain] o.s.c.support.DefaultLifecycleProcessor  : Starting beans in phase 2147483647
2017-08-04 14:43:54.255  INFO 12156 --- [restartedMain] d.s.w.p.DocumentationPluginsBootstrapper : Context refreshed
2017-08-04 14:43:54.277  INFO 12156 --- [restartedMain] d.s.w.p.DocumentationPluginsBootstrapper : Found 1 custom documentation plugin(s)
2017-08-04 14:43:54.326  INFO 12156 --- [restartedMain] s.d.s.w.s.ApiListingReferenceScanner     : Scanning for api listing references
2017-08-04 14:43:54.761  WARN 12156 --- [restartedMain] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Failed to start bean 'documentationPluginsBootstrapper'; nested exception is com.google.common.util.concurrent.ExecutionError: java.lang.StackOverflowError
2017-08-04 14:43:54.762  INFO 12156 --- [restartedMain] o.s.j.e.a.AnnotationMBeanExporter        : Unregistering JMX-exposed beans on shutdown
2017-08-04 14:43:54.768  INFO 12156 --- [restartedMain] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
2017-08-04 14:43:54.773  INFO 12156 --- [restartedMain] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]
2017-08-04 14:43:54.775  INFO 12156 --- [localhost-startStop-1] c.q.fw.core.filter.WebRequestParmFilter  : 过滤器销毁
2017-08-04 14:43:54.788  INFO 12156 --- [restartedMain] utoConfigurationReportLoggingInitializer : 

Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
2017-08-04 14:43:54.799 ERROR 12156 --- [restartedMain] o.s.boot.SpringApplication               : Application startup failed

org.springframework.context.ApplicationContextException: Failed to start bean 'documentationPluginsBootstrapper'; nested exception is com.google.common.util.concurrent.ExecutionError: java.lang.StackOverflowError
    at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:178)  ~[spring-context-4.3.10.RELEASE.jar:4.3.10.RELEASE]
    at org.springframework.context.support.DefaultLifecycleProcessor.access$200(DefaultLifecycleProcessor.java:50) ~[spring-context-4.3.10.RELEASE.jar:4.3.10.RELEASE]
    at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:348) ~[spring-context-4.3.10.RELEASE.jar:4.3.10.RELEASE]
    at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:151) ~[spring-context-4.3.10.RELEASE.jar:4.3.10.RELEASE]
    at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:114) ~[spring-context-4.3.10.RELEASE.jar:4.3.10.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:880) ~[spring-context-4.3.10.RELEASE.jar:4.3.10.RELEASE]
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.finishRefresh(EmbeddedWebApplicationContext.java:144) ~[spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:546) ~[spring-context-4.3.10.RELEASE.jar:4.3.10.RELEASE]
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693) [spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360) [spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) [spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118) [spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107) [spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE]
    at com.qipai.MemberMsApplication.main(MemberMsApplication.java:12) [classes/:na]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_121]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_121]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_121]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_121]
    at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) [spring-boot-devtools-1.5.6.RELEASE.jar:1.5.6.RELEASE]
Caused by: com.google.common.util.concurrent.ExecutionError: java.lang.StackOverflowError
    at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2216) ~[guava-22.0.jar:na]
    at com.google.common.cache.LocalCache.get(LocalCache.java:4147) ~[guava-22.0.jar:na]
    at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:4151) ~[guava-22.0.jar:na]
    at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:5140) ~[guava-22.0.jar:na]
    at com.google.common.cache.LocalCache$LocalLoadingCache.getUnchecked(LocalCache.java:5146) ~[guava-22.0.jar:na]
    at springfox.documentation.spring.web.scanners.CachingOperationReader.read(CachingOperationReader.java:57) ~[springfox-spring-web-2.6.1.jar:2.6.1]
    at springfox.documentation.spring.web.scanners.ApiDescriptionReader.read(ApiDescriptionReader.java:66) ~[springfox-spring-web-2.6.1.jar:2.6.1]
    at springfox.documentation.spring.web.scanners.ApiListingScanner.scan(ApiListingScanner.java:89) ~[springfox-spring-web-2.6.1.jar:2.6.1]
    at springfox.documentation.spring.web.scanners.ApiDocumentationScanner.scan(ApiDocumentationScanner.java:70) ~[springfox-spring-web-2.6.1.jar:2.6.1]
    at springfox.documentation.spring.web.plugins.DocumentationPluginsBootstrapper.scanDocumentation(DocumentationPluginsBootstrapper.java:85) ~[springfox-spring-web-2.6.1.jar:2.6.1]
    at springfox.documentation.spring.web.plugins.DocumentationPluginsBootstrapper.start(DocumentationPluginsBootstrapper.java:127) ~[springfox-spring-web-2.6.1.jar:2.6.1]
    at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:175) ~[spring-context-4.3.10.RELEASE.jar:4.3.10.RELEASE]
    ... 19 common frames omitted
Caused by: java.lang.StackOverflowError: null
    at com.fasterxml.classmate.util.ResolvedTypeCache$Key.equals(ResolvedTypeCache.java:153) ~[classmate-1.3.3.jar:1.3.3]
    at java.util.HashMap.getNode(HashMap.java:571) ~[na:1.8.0_121]
    at java.util.LinkedHashMap.get(LinkedHashMap.java:440) ~[na:1.8.0_121]
    at com.fasterxml.classmate.util.ResolvedTypeCache.find(ResolvedTypeCache.java:53) ~[classmate-1.3.3.jar:1.3.3]
    at com.fasterxml.classmate.TypeResolver._fromClass(TypeResolver.java:366) ~[classmate-1.3.3.jar:1.3.3]
    at com.fasterxml.classmate.TypeResolver._fromAny(TypeResolver.java:312) ~[classmate-1.3.3.jar:1.3.3]
    at com.fasterxml.classmate.TypeResolver.resolve(TypeResolver.java:174) ~[classmate-1.3.3.jar:1.3.3]
    at com.fasterxml.classmate.ResolvedTypeWithMembers.resolveField(ResolvedTypeWithMembers.java:551) ~[classmate-1.3.3.jar:1.3.3]
    at com.fasterxml.classmate.ResolvedTypeWithMembers.resolveMemberFields(ResolvedTypeWithMembers.java:300) ~[classmate-1.3.3.jar:1.3.3]
    at com.fasterxml.classmate.ResolvedTypeWithMembers.getMemberFields(ResolvedTypeWithMembers.java:193) ~[classmate-1.3.3.jar:1.3.3]
    at springfox.documentation.schema.property.field.FieldProvider.in(FieldProvider.java:47) ~[springfox-schema-2.6.1.jar:2.6.1]
    at springfox.documentation.spring.web.readers.parameter.ModelAttributeParameterExpander.expand(ModelAttributeParameterExpander.java:80) ~[springfox-spring-web-2.6.1.jar:2.6.1]
    at springfox.documentation.spring.web.readers.parameter.ModelAttributeParameterExpander.expand(ModelAttributeParameterExpander.java:94) ~[springfox-spring-web-2.6.1.jar:2.6.1]
    at springfox.documentation.spring.web.readers.parameter.ModelAttributeParameterExpander.expand(ModelAttributeParameterExpander.java:94) ~[springfox-spring-web-2.6.1.jar:2.6.1]
    at springfox.documentation.spring.web.readers.parameter.ModelAttributeParameterExpander.expand(ModelAttributeParameterExpander.java:94) ~[springfox-spring-web-2.6.1.jar:2.6.1]
    at springfox.documentation.spring.web.readers.parameter.ModelAttributeParameterExpander.expand(ModelAttributeParameterExpander.java:94) ~[springfox-spring-web-2.6.1.jar:2.6.1]
    at springfox.documentation.spring.web.readers.parameter.ModelAttributeParameterExpander.expand(ModelAttributeParameterExpander.java:94) ~[springfox-spring-web-2.6.1.jar:2.6.1]
    at springfox.documentation.spring.web.readers.parameter.ModelAttributeParameterExpander.expand(ModelAttributeParameterExpander.java:94) ~[springfox-spring-web-2.6.1.jar:2.6.1]
    at springfox.documentation.spring.web.readers.parameter.ModelAttributeParameterExpander.expand(ModelAttributeParameterExpander.java:94) ~[springfox-spring-web-2.6.1.jar:2.6.1]
    at springfox.documentation.spring.web.readers.parameter.ModelAttributeParameterExpander.expand(ModelAttributeParameterExpander.java:94) ~[springfox-spring-web-2.6.1.jar:2.6.1]
    at springfox.documentation.spring.web.readers.parameter.ModelAttributeParameterExpander.expand(ModelAttributeParameterExpander.java:94) ~[springfox-spring-web-2.6.1.jar:2.6.1]
    at springfox.documentation.spring.web.readers.parameter.ModelAttributeParameterExpander.expand(ModelAttributeParameterExpander.java:94) ~[springfox-spring-web-2.6.1.jar:2.6.1]
    at springfox.documentation.spring.web.readers.parameter.ModelAttributeParameterExpander.expand(ModelAttributeParameterExpander.java:94) ~[springfox-spring-web-2.6.1.jar:2.6.1]
    at springfox.documentation.spring.web.readers.parameter.ModelAttributeParameterExpander.expand(ModelAttributeParameterExpander.java:94) ~[springfox-spring-web-2.6.1.jar:2.6.1]
    at springfox.documentation.spring.web.readers.parameter.ModelAttributeParameterExpander.expand(ModelAttributeParameterExpander.java:94) ~[springfox-spring-web-2.6.1.jar:2.6.1]
    at springfox.documentation.spring.web.readers.parameter.ModelAttributeParameterExpander.expand(ModelAttributeParameterExpander.java:94) ~[springfox-spring-web-2.6.1.jar:2.6.1]
    at springfox.documentation.spring.web.readers.parameter.ModelAttributeParameterExpander.expand(ModelAttributeParameterExpander.java:94) ~[springfox-spring-web-2.6.1.jar:2.6.1]
    at springfox.documentation.spring.web.readers.parameter.ModelAttributeParameterExpander.expand(ModelAttributeParameterExpander.java:94) ~[springfox-spring-web-2.6.1.jar:2.6.1]
    at springfox.documentation.spring.web.readers.parameter.ModelAttributeParameterExpander.expand(ModelAttributeParameterExpander.java:94) ~[springfox-spring-web-2.6.1.jar:2.6.1]
    at springfox.documentation.spring.web.readers.parameter.ModelAttributeParameterExpander.expand(ModelAttributeParameterExpander.java:94) ~[springfox-spring-web-2.6.1.jar:2.6.1]
    at springfox.documentation.spring.web.readers.parameter.ModelAttributeParameterExpander.expand(ModelAttributeParameterExpander.java:94) ~[springfox-spring-web-2.6.1.jar:2.6.1]
    at springfox.documentation.spring.web.readers.parameter.ModelAttributeParameterExpander.expand(ModelAttributeParameterExpander.java:94) ~[springfox-spring-web-2.6.1.jar:2.6.1]
    at springfox.documentation.spring.web.readers.parameter.ModelAttributeParameterExpander.expand(ModelAttributeParameterExpander.java:94) ~[springfox-spring-web-2.6.1.jar:2.6.1]

问题的原因

项目是基于Spring Boot搭建的RESTFUL风格的项目。在写Controller的时候,封装了两层。一个是接口,一个是具体实现。问题的原因就出在了实现类的Controller中方法的参数没有加注解,只在接口中写了注解。把注解加上,问题就解决了。
下面是问题代码:
ILabelController

@RequestMapping("/label")
public interface ILabelController {

    @ApiOperation(value = "新增标签")
    @RequestMapping(value = "/dict/add", method = RequestMethod.POST)
    void addLabelDict(@RequestBody @Valid LabelDictDomain labelDict);
    
    @ApiOperation(value = "删除标签")
    @RequestMapping(value = "/dict/delete/{id}" , method = RequestMethod.DELETE)
    void deleteLabelDict(@PathVariable("id")String id);
    
    @ApiOperation(value = "对标签字典的复合查询", notes = "对标签字典的复合查询")
    @RequestMapping(value = "/dict/search", method = RequestMethod.GET)
    List<LabelDictDomain> searchLabelDict(@RequestParam(value = "name", required = false)String labelName,
            @RequestParam(value = "type", required = false)String labelType, 
            @RequestParam(value = "group", required = false)String labelGroup);
    
    @ApiOperation(value = "新增或修改一个会员固定标签", notes = "新增或修改一个会员固定标签")
    @RequestMapping(value = "/member/add_fixed", method = RequestMethod.POST)
    void addFixedMemberLabel(@RequestBody @Valid MemberLabelDomain memberLabel);
    
    @ApiOperation(value = "新增或修改一个会员个性标签", notes = "新增或修改一个会员个性标签")
    @RequestMapping(value = "/member/add_personal", method = RequestMethod.POST)
    void addPersonalMemberLabel(@RequestBody @Valid @NotNull MemberDomain memberDomain,@RequestBody @Valid @NotNull LabelDictDomain labelDictDomain);

    @ApiOperation(value = "删除会员标签", notes = "删除会员标签")
    @RequestMapping(value = "/member/delete/{id}", method = RequestMethod.DELETE)
    void deleteMemberLabel(@PathVariable("id")String id);
    
    @ApiOperation(value = "获取会员标签", notes = "获取会员标签")
    @RequestMapping(value = "/member/get/{memberCode}", method = RequestMethod.GET)
    List<LabelDictDomain> searchMemberLabel(@PathVariable("memberCode")String memberCode);
}

LabelController

@RestController
public class LabelController implements ILabelController {
    private final Logger logger = LoggerFactory.getLogger(this.getClass());
    @Autowired
    ILabelDictService dictService;
    @Autowired
    IMemberLabelService memberLabelService;
    @Override
    public void addLabelDict(LabelDictDomain labelDict) {
        dictService.save(labelDict);
    }
    
    @Override
    public void deleteLabelDict(String id) {
        dictService.deleteById(id);
        
    }

    @Override
    public List<LabelDictDomain> searchLabelDict(String labelName,String labelType, String labelGroup) {
        return dictService.findLabelByKey(labelName, labelType, labelGroup);
    }

    @Override
    public void addFixedMemberLabel(MemberLabelDomain memberLabel) {
        memberLabelService.save(memberLabel);
    }

    @Override
    public void addPersonalMemberLabel(MemberDomain memberDomain, LabelDictDomain labelDictDomain) {
        logger.info("新增会员个性标签");
        dictService.save(labelDictDomain);
        LabelDictDomain label = dictService.findLabelByLabelName(labelDictDomain.getLabelName());
        memberLabelService.setMemberLabel(new MemberLabelDomain(memberDomain,label));
        
    }

    @Override
    public void deleteMemberLabel(String id) {
        memberLabelService.deleteById(id);
        
    }

    @Override
    public List<LabelDictDomain> searchMemberLabel(String memberCode) {
        logger.info("查询会员标签");
        List<MemberLabelDomain> list = memberLabelService.getMemberLabels(memberCode);
        List<LabelDictDomain> listReturn = new ArrayList<>();
        for (MemberLabelDomain memberLabelDomain : list) {
            listReturn.add(memberLabelDomain.getLabelDictDomain());
        }
        return listReturn;
    }



}

解决问题修改的代码

LabelController

@RestController
public class LabelController implements ILabelController {
    private final Logger logger = LoggerFactory.getLogger(this.getClass());
    @Autowired
    ILabelDictService dictService;
    @Autowired
    IMemberLabelService memberLabelService;
    @Override
    public void addLabelDict(@RequestBody @Valid LabelDictDomain labelDict) {
        dictService.save(labelDict);
    }
    
    @Override
    public void deleteLabelDict(@PathVariable("id")String id) {
        dictService.deleteById(id);
        
    }

    @Override
    public List<LabelDictDomain> searchLabelDict(@RequestParam(value = "name", required = false)String labelName,
            @RequestParam(value = "type", required = false)String labelType, 
            @RequestParam(value = "group", required = false)String labelGroup) {
        return dictService.findLabelByKey(labelName, labelType, labelGroup);
    }

    @Override
    public void addFixedMemberLabel(@RequestBody @Valid  MemberLabelDomain memberLabel) {
        memberLabelService.save(memberLabel);
    }

    @Override
    public void addPersonalMemberLabel(@RequestBody @Valid @NotNull MemberDomain memberDomain, @RequestBody @Valid @NotNull LabelDictDomain labelDictDomain) {
        logger.info("新增会员个性标签");
        dictService.save(labelDictDomain);
        LabelDictDomain label = dictService.findLabelByLabelName(labelDictDomain.getLabelName());
        memberLabelService.setMemberLabel(new MemberLabelDomain(memberDomain,label));
        
    }

    @Override
    public void deleteMemberLabel(@PathVariable("id")String id) {
        memberLabelService.deleteById(id);
        
    }

    @Override
    public List<LabelDictDomain> searchMemberLabel(@PathVariable("memberCode")String memberCode) {
        logger.info("查询会员标签");
        List<MemberLabelDomain> list = memberLabelService.getMemberLabels(memberCode);
        List<LabelDictDomain> listReturn = new ArrayList<>();
        for (MemberLabelDomain memberLabelDomain : list) {
            listReturn.add(memberLabelDomain.getLabelDictDomain());
        }
        return listReturn;
    }



}

THE END

希望我的文章对你能有所帮助。
有什么意见、见解或疑惑,欢迎留言讨论。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 203,547评论 6 477
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 85,399评论 2 381
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 150,428评论 0 337
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 54,599评论 1 274
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 63,612评论 5 365
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,577评论 1 281
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 37,941评论 3 395
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,603评论 0 258
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 40,852评论 1 297
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,605评论 2 321
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,693评论 1 329
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,375评论 4 318
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 38,955评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,936评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,172评论 1 259
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 43,970评论 2 349
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,414评论 2 342

推荐阅读更多精彩内容