簡體   English   中英

錯誤 java.lang.IllegalArgumentException:參數類型的名稱 [java.lang.String]

[英]Error java.lang.IllegalArgumentException: Name for argument type [java.lang.String]

2 周以來,我一直在努力尋找解決此錯誤的方法。 你能幫我看看發生了什么嗎

這是錯誤堆棧跟蹤:

“java.lang.IllegalArgumentException:參數類型 [java.lang.String] 的名稱不可用,並且在類文件中也找不到參數名稱信息。\\r\\n\\tat org.springframework.util.Assert.notNull(Assert. java:112)\\r\\n\\tat org.springframework.web.method.annotation.AbstractNamedValueMethodArgumentResolver.updateNamedValueInfo(AbstractNamedValueMethodArgumentResolver.java:138)\\r\\n\\tat org.springframework.web.method.annotation.MethodArgumentResolver.updateNamedValueInfo(AbstractNamedValueMethodArgumentResolver.java:138)\\r\\n\\tat org.springframework.web.method.annotation.MethodArgumentResolver.updateNamedValueInfo AbstractNamedValueMethodArgumentResolver.java:117)\\r\\n\\tat org.springframework.web.method.annotation.AbstractNamedValueMethodArgumentResolver.resolveArgument(AbstractNamedValueMethodArgumentResolver.java:84)\\r\\n\\tat org.methodspringframework.web.method.annotation.AbstractNamedValueMethodArgumentResolver.resolveArgument(AbstractNamedValueMethodArgumentResolver.java:84)\\r\\n\\tat org.methodspringframework.web.method.annotation.AbstractNamedValueMethodArgumentResolver. resolveArgument(HandlerMethodArgumentResolverComposite.java:77)\\r\\n\\tat org.springframework.web.method.support.InvocableHandlerMethod.getMethodArgumentValues(InvocableHandlerMethod.java:162)\\r\\n\\tat org.springfra mework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:123)\\r\\n\\tat org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104)\\r \\n\\tat org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:745)\\r\\n\\tat org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter。 handleInternal(RequestMappingHandlerAdapter.java:686)\\r\\n\\tat org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)\\r\\n\\tat org.springframework.web.servlet. DispatcherServlet.doDispatch(DispatcherServlet.java:925)\\r\\n\\tat org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)\\r\\n\\tat org.springframework.web.servlet.FrameworkServlet。 processRequest(FrameworkServlet.java:936)\\r\\n\\tat org.springframework.web.servlet.Fr ameworkServlet.doGet(FrameworkServlet.java:827)\\r\\n\\tat javax.servlet.http.HttpServlet.service(HttpServlet.java:735)\\r\\n\\tat org.springframework.web.servlet.FrameworkServlet.service( FrameworkServlet.java:812)\\r\\n\\tat javax.servlet.http.HttpServlet.service(HttpServlet.java:848)\\r\\n\\tat org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:第 684 章82)\\r\\n\\tat org.eclipse.jetty.servlets.GzipFilter.doFilter(GzipFilter.java:294)\\r\\n\\tat org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java: 1484)\\r\\n\\tat org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)\\r\\n\\tat org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke FilterSecurityInterceptor.java:118)\\r\\n\\tat org.springframework.security.web.access.in tercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84)\\r\\n\\tat org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)\\r\\n\\tat org.springframework.security。 web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)\\r\\n\\tat org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)\\r\\n\\tat org.springframework。 security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:103)\\r\\n\\tat org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)\\r\\n\\tat org. springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113)\\r\\n\\tat org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)\\r\\n\\tat org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilt er(SecurityContextHolderAwareRequestFilter.java:54)\\r\\n\\tat org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)\\r\\n\\tat org.springframework.security.web.savedrequest。 RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45)\\r\\n\\tat org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)\\r\\n\\tat org.springframework.security.web。 authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:183)\\r\\n\\tat org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)\\r\\n\\tat org.springframework.security。 web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105)\\r\\n\\tat org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)\\r\\n\\tat org. springframework.security.web.session.ConcurrentSessionFilter.doFilter(ConcurrentSessionFilter.java:125) \\r\\n\\tat org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)\\r\\n\\tat org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java: 87)\\r\\n\\tat org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)\\r\\n\\tat org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java: 192)\\r\\n\\tat org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160)\\r\\n\\tat org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:343) \\r\\n\\tat org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:260)\\r\\n\\tat org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1476) \\r\\n\\tat org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:499)\\r\\n\\tat org.eclipse.jetty.server.handler.ScopedHandler。 句柄(ScopedHandler.java:137)\\r\\n\\tat org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:557)\\r\\n\\tat org.eclipse.jetty.server.session.SessionHandler。 doHandle(SessionHandler.java:231)\\r\\n\\tat org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1086)\\r\\n\\tat org.eclipse.jetty.servlet.ServletHandler。 doScope(ServletHandler.java:428)\\r\\n\\tat org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193)\\r\\n\\tat org.eclipse.jetty.server.handler。 ContextHandler.doScope(ContextHandler.java:1020)\\r\\n\\tat org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)\\r\\n\\tat org.eclipse.jetty.server。 handler.HandlerCollection.handle(HandlerCollection.java:154)\\r\\n\\tat org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)\\r\\n\\tat org.eclipse.jetty。 server.Server.handle(Server.java:370)\\r\\n\\tat org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:494)\\r\\n\\tat org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:971)\\r\\n\\tat org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:1033)\\r\\n\\tat org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:644)\\r\\n\\tat org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:235)\\r\\n\\tat org. eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82)\\r\\n\\tat org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:667)\\r\\n\\tat org. eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:52)\\r\\n\\tat org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)\\r\\n\\ tat org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)\\r\\n\\tat java.lang.Thread.run(Thread.java:748)\\r\\n"

您很可能試圖將參數作為 String 傳遞給不應接受 String 作為參數或根本不接受任何參數的地方。

正如其中一位評論所說,您可以在這里發布您的代碼嗎? 日志也沒有說明您的特定類中的哪個有異常。

我懷疑您有一些 Spring MVC 控制器,並希望 Spring 自動按名稱匹配控制器方法參數和請求參數。

根據本文在此處輸入鏈接描述,這僅在您的代碼已使用調試信息(javac -g 選項)編譯時才有效。

我也很難解決這個問題。 它在我的 IDE 中有效,但在將 ant 構建部署到 tomcat 時無效。 當我嘗試遠程調試 tomcat 並因此添加 javac 調試選項時,它突然起作用了。 但是,我沒有看到調試選項和我正在尋找的問題之間的關系;-)

實際上,這里 String 類型不可用,這意味着如果我們提供參數:@Requestparam(value = "myString") String myString 如果我們像 @Requestparam String myString 這樣提供它,很可能會得到該錯誤。

當該方法未針對字符串添加 @RequestParam 注釋時,我們遇到了同樣的錯誤。 這個錯誤是我們開始通過Jenkins使用Ant Build時產生的。 通過Eclipse IDE導出WAR文件時不會出現。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM