springcloud常见错误

本文列举了SpringCloud中常见的错误,包括版本冲突、jar包损坏、应用名称配置错误、服务启动顺序不当、Loc header异常、找不到方法、端口占用、FastDFS错误码解析、Solr相关问题以及页面Thymeleaf的注意事项。详细分析了错误原因并提供了解决方案。
摘要由CSDN通过智能技术生成
  1. Unsatisfied dependency expressed through field
    feign 接口参数注解RequestParam,应写成RequestParam(“userName”)

  2. mybatisplus,mybatis 会默认链接数据库
    需要配置datasource,4属性,否则报not dataSource 错误

  3. Required String parameter ‘userName’ is not present 属性类的参数不能加@RequestParam注解

  4. 415错误:页面调用的第一个控制层参数 属性类对象,因为页面传过来是json数据

  5. 400错误:请求无效,页面调用的第一个控制层 属性类列参数 不能加注解,或注解名字,打开检查才能看到错误信息

  6. 服务端控制层不加注解,会提示新增成功,但获取不到参数

  7. 405错误:post方法等调用不匹配,如URL为get请求,只能访问getMapping

  8. springcloud中,getMapping请求传参为属性类对象时,请求类型会 默认成为POST,然后报405错误,所以get方式不能传对象

  9. 404错误: 路径错误,很可能是注解名不匹配

  10. 500错误:后台代码报错,需根据错误具体分析,
    如:路径参数应该用@PathVariable,却使用了request如路径参数应该用@PathVariable,却使用了request
    如:控制层加了@RequestParam注解,参数默认初始化没有此参数 等等·······

  11. 使用mybatis时分页栏有问题,可能是pagehelper版本太低

12. 版本冲突,jar包损坏 问题最为常见

如:有依赖非springboot集成依赖,本该mybatis-plus-boot-starter ,实际下载成 mybatis-plus

Unsatisfied dependency expressed through field 'service'; 
nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: 
Error creating bean with name 'sqlServiceImpl': 
Unsatisfied dependency expressed through field 'empMapper';
nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'empMapper' defined in file 
[E:\SpringCloudFeign\SPRINGCLOUD_SERVICE\target\classes\cn\ps\mapper\EmpMapper.class]:
Invocation of init method failed; 
nested exception is java.lang.IllegalArgumentException: 
Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required

13. application.name错误

spring:
application:
name: Schoo
github上名字为:School-dev.yml
应为 School

2018-12-04 00:11:23.183  WARN 7804 --- [  restartedMain] ationConfigEmbeddedWebApplicationContext :
    Exception encountered during context initialization - cancelling refresh attempt: 
    org.springframework.beans.factory.UnsatisfiedDependencyException: 
    Error creating bean with name 'inMemoryDatabaseShutdownExecutor' defined in class path resource 
    [org/springframework/boot/devtools/autoconfigure/DevToolsDataSourceAutoConfiguration.class]:
    Unsatisfied dependency expressed through method 'inMemoryDatabaseShutdownExecutor' parameter 0;
    nested exception is org.springframework.beans.factory.BeanCreationException:
    Error creating bean with name 'dataSource' defined in class path resource 

14. 错误:服务启动时间早于注册中心,应先启动注册中心,然后启动服务,最后起客户端

Cannot execute request on any known server

2018-12-04 08:11:31.965  WARN 5796 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient: 
DiscoveryClient_USERSERVICE/OuYang:
userService:8881 - registration failed Cannot execute request on any known server
com.netflix.discovery.shared.transport.TransportException: Cannot execute request on any known server

15. 异常:loc header execption 一定是jar包损坏

16. 异常: 有依赖,却找不到方法,也一定是jar包损坏,找到相应的路径,删掉重新运行即可

17. 端口被占用错误

Description:

The Tomcat connector configured to listen on port 83 failed to start. 
~~The port may already be in use or the connector may be misconfigured~~ 
··········································································
Action:

Verify the connector's configuration, identify and stop any process that's listening on port 83, 
or configure this application to listen on another port.

18. 开发者工具集,代码跟新会自动刷新,所以客户端开不了两个,启动第二个汇报端口被占用错误,依赖如下,错误同 17. 端口被占用错误

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-devtools</artifactId>
    <optional>true</optional>
</dependency>

19. fastdfs 分布式文件系统 错误码22:

编码格式错误

String filename = URLEncoder.encode(map.get("filename").toString(),"UTF-8");
String groupname =  map.get("groupname").toString();
String filepath =map.get("filepath").toString();


    2018-12-05 01:28:00.052 ERROR 6164 --- [nio-8899-exec-3] o.a.c.c.C.[.[.[/].[dispatcherServlet]    
    Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; 
    nested exception is com.luhuiguo.fastdfs.exception.FdfsServerException: 错误码:22,错误信息:无效的参数] with root cause
 
    com.luhuiguo.fastdfs.exception.FdfsServerException: 错误码:22,错误信息:无效的参数
    	at com.luhuiguo.fastdfs.exception.FdfsServerException.byCode(FdfsServerException.java:54) ~[fastdfs-client-0.4.0.jar:na]
    	at com.luhuiguo.fastdfs.proto.ProtoHead.validateResponseHead(ProtoHead.java:119) ~[fastdfs-client-0.4.0.jar:na]
    	at com.luhuiguo.fastdfs.proto.AbstractFdfsCommand.receive(AbstractFdfsCommand.java:102) ~[fastdfs-client-0.4.0.jar:na]
    	at com.luhuiguo.fastdfs.proto.AbstractFdfsCommand.execute(AbstractFdfsCommand.java:45) ~[fastdfs-client-0.4.0.jar:na]
    	at com.luhuiguo.fastdfs.conn.ConnectionManager.execute(ConnectionManager.java:73) ~[fastdfs-client-0.4.0.jar:na]
    	at com.luhuiguo.fastdfs.conn.ConnectionManager.executeFdfsCmd(ConnectionManager.java:58) ~[fastdfs-client-0.4.0.jar:na]
    	at com.luhuiguo.fastdfs.service.DefaultGenerateStorageClient.downloadFile(DefaultGenerateStorageClient.java:151) ~[fastdfs-client-0.4.0.jar:na]

20. fastdfs 分布式文件系统 错误码2:

storage 容器IP没改,应改成linux系统的ip
在这里插入图片描述

21. weindow操作错误

C:\Users\Administrator>telnet 192.168.174.130 8983
'telnet' 不是内部或外部命令,也不是可运行的程序或批处理文件。

解决:打开控制面板→程序和功能→打开或关闭windows功能→勾选相关操作

在这里插入图片描述

许多错误需要在页面打开检查或F12,点开错误才能看到提示如400

· 400错误合集

常见web错误码 404 500 404表示文件或资源未找到 java WEB常见的错误代码

                 11xx-信息提示:这些状态代码表示临时的响应。客户端在收到常规响应之前,应准备接收一个或多个1xx响应。 100-继续。
                 101-切换协议。 22xx-成功:这类状态代码表明服务器成功地接受了客户端请求。 200-确定。客户端请求已成功。
                 201-已创建。 202-已接受。 203-非权威性信息。 204-无内容。 205-重置内容。 206-部分内容。
                 33xx-重定向:客户端浏览器必须采取更多操作来实现请求。例如,浏览器可能不得不请求服务器上的不同的页面,或通过代理服务器重复该请求。
                 301-对象已永久移走,即永久重定向。 302-对象已临时移动。 304-未修改。 307-临时重定向。
                 44xx-客户端错误:发生错误,客户端似乎有问题。例如,客户端请求不存在的页面,客户端未提供有效的身份验证信息。400-错误的请求。
                 401-访问被拒绝。IIS定义了许多不同的401错误,它们指明更为具体的错误原因。这些具体的错误代码在浏览器中显示,但不在IIS日志中显示:
                 401.1-登录失败。
                 401.2-服务器配置导致登录失败。
                 401.3-由于ACL对资源的限制而未获得授权。
                 401.4-筛选器授权失败。
                 401.5-ISAPI/CGI应用程序授权失败。
                 401.7–访问被Web服务器上的URL授权策略拒绝。这个错误代码为IIS6.0所专用。 403-禁止访问:IIS定义了许多不同的403错误,它们指明更为具体的错误原因:
                 403.1-执行访问被禁止。
                 403.2-读访问被禁止。
                 403.3-写访问被禁止。
                 403.4-要求SSL403.5-要求SSL128403.6-IP地址被拒绝。
                 403.7-要求客户端证书。
                 403.8-站点访问被拒绝。
                 403.9-用户数过多。
                 403.10-配置无效。
                 403.11-密码更改。
                 403.12-拒绝访问映射表。
                 403.13-客户端证书被吊销。
                 403.14-拒绝目录列表。
                 403.15-超出客户端访问许可。
                 403.16-客户端证书不受信任或无效。
                 403.17-客户端证书已过期或尚未生效。
                 403.18-在当前的应用程序池中不能执行所请求的URL。这个错误代码为IIS6.0所专用。
                 403.19-不能为这个应用程序池中的客户端执行CGI。这个错误代码为IIS6.0所专用。
                 403.20-Passport登录失败。这个错误代码为IIS6.0所专用。 404-未找到。
                 404.0-(无)–没有找到文件或目录。
                 404.1-无法在所请求的端口上访问Web站点。
                 404.2-Web服务扩展锁定策略阻止本请求。
                 404.3-MIME映射策略阻止本请求。 405-用来访问本页面的HTTP谓词不被允许(方法不被允许) 406-客户端浏览器不接受所请求页面的MIME类型。 407-要求进行代理身份验证。 412-前提条件失败。
                 413–请求实体太大。 414-请求URI太长。 415–不支持的媒体类型。 416–所请求的范围无法满足。 417–执行失败。
                 423–锁定的错误。 55xx-服务器错误:服务器由于遇到错误而不能完成该请求。 500-内部服务器错误。

· 500错误大全

 			500.12-应用程序正忙于在Web服务器上重新启动。
                   500.13-Web服务器太忙。
                   500.15-不允许直接请求Global.asa。
                   500.16–UNC授权凭据不正确。这个错误代码为IIS6.0所专用。
                   500.18–URL授权存储不能打开。这个错误代码为IIS6.0所专用。
                   500.100-内部ASP错误。 501-页眉值指定了未实现的配置。 502-Web服务器用作网关或代理服务器时收到了无效响应。
                   502.1-CGI应用程序超时。
                   502.2-CGI应用程序出错。application. 503-服务不可用。这个错误代码为IIS6.0所专用。 504-网关超时。 505-HTTP版本不受支持。

22. Solr极速索引查询:404错误

原因: 属性类注解 @SolrDocument应改为@SolrDocument(solrCoreName=“mycore1”)

<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Error 404 Not Found</title>
</head>
<body><h2>HTTP ERROR 404</h2>
<p>Problem accessing /solr/entity/select. Reason:
<pre>    Not Found</pre></p><hr><i><small>Powered by Jetty://</small></i><hr/>

</body>
</html>
; nested exception is org.apache.solr.client.solrj.impl.HttpSolrClient$RemoteSolrException: Error from server at http://192.168.174.131:8983/solr: Expected mime type application/octet-stream but got text/html. <html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Error 404 Not Found</title>
</head>
<body><h2>HTTP ERROR 404</h2>
<p>Problem accessing /solr/entity/select. Reason:
<pre>    Not Found</pre></p><hr><i><small>Powered by Jetty://</small></i><hr/>

</body>
</html>
] with root cause

org.apache.solr.client.solrj.impl.HttpSolrClient$RemoteSolrException: Error from server at http://
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值