問題記錄整理(持續更新)

Java


SSL
javax.net.ssl.SSLHandshakeException: Remote host terminated the handshake

指向HTTPS證書過期

SpringBoot


Springboot項目配置jar外部靜態文件
spring.resources.static-locations=file:/Users/gaojiaqi/Desktop/test,classpath:/META-INF/resources/,classpath:/resources/,classpath:/static/,classpath:/public/
Swagger
java.lang.NumberFormatException: For input string: ""

Swagger的@ApiModelProperty標記Integer屬性時,需要指定example值,example默認值是空字符串,如未指定則會報這個問題。

JPA
java.sql.SQLSyntaxErrorException: Table 'cds.hibernate_sequence' doesn't exist

背景:
使用@GeneratedValue後
解決方法:
spring.jpa.hibernate.use-new-id-generator-mappings=false 或 @GeneratedValue(strategy = GenerationType.IDENTITY)

SpringCloud


Gateway 不能使用 web MVC框架
Consider defining a bean of type 'org.springframework.http.codec.ServerCodecConfigurer' in your configuration.

spring-boot-starter-web與spring-cloud-starter-gateway存在jar包衝突
Spring Cloud Gateway 是使用 netty+webflux 實現因此不需要再引入 web 模塊。


Feign 每個參數需要指定PathVariable
java.lang.IllegalStateException: PathVariable annotation was empty on param 0.

使用Spring Cloud Feign 的時候,如果參數中帶有@PathVariable形式的參數,則要用value=""標明對應的參數,否則會拋出IllegalStateException異常
如:@PathVariable(value = “groupType”) String groupType


漏傳參數
java.lang.IllegalArgumentException: Body parameter 0 was null

Spring Cloud Feign 遠程調用需要攜帶參數,但實際上沒沒有攜帶


Gateway requestBody 只允許讀取一次
java.lang.IllegalStateException: Only one connection receive subscriber allowed.

Spring Cloud Gateway 中,requestBody只允許讀取一次,解決方法就是讀取後需要在寫入一個request。

Dubbo


Dubbo Qos 22222
ERROR org.apache.dubbo.qos.server.Server (Server.java:103) -  [DUBBO] qos-server can not bind localhost:22222, dubbo version: 2.7.3, current host: 192.168.0.1

Qos=Quality of Service,qos是Dubbo的在線運維命令,可以對服務進行動態的配置、控制及查詢,Dubboo2.5.8新版本重構了telnet(telnet是從Dubbo2.0.5開始支持的)模塊,提供了新的telnet命令支持,新版本的telnet端口與dubbo協議的端口是不同的端口,默認爲22222,可以通過配置文件dubbo.properties修改。telnet 模塊現在同時支持 http 協議和 telnet 協議,方便各種情況的使用。
在同時啓動多個dubbo應用的時候,會報這個錯誤。

ES相關


節點網絡連接問題
None of the configured nodes are available: []

RocketMQ

CODE: 14 DESC: service not available now, maybe disk full, CL: 0.96 CQ: 0.96

RocketMQ磁盤滿,需清理磁盤

數據庫相關


mysql排序穩定性問題


Timestamp 數據異常
Cause: java.sql.SQLException: Zero date value prohibited
com.mysql.cj.core.exceptions.DataReadException: Zero date value prohibited

數據時區錯誤,由於數據庫字段timestamp類型有時間0000-00-00 00:00:00,修改爲正常時間即可。
timestamp的默認值:CURRENT_TIMESTAMP(插入時個更新時間)、ON UPDATE CURRENT_TIMESTAMP(僅在更新時設置時間,插入時賦值)、CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP (創建和修改時都修改此值)


Cause: java.sql.SQLException: Incorrect DECIMAL value: '0' for column '' at row -1
; uncategorized SQLException for SQL []; SQL state [HY000]; error code [1366]; Incorrect DECIMAL value: '0' for column '' at row -1; nested exception is java.sql.SQLException: Incorrect DECIMAL value: '0' for column '' at row -1

根本解法:對數據輸入嚴格校驗,避免出現cast轉換值爲null的情況,或者對於null的情況從邏輯上進行控制


Cause: org.mybatis.spring.MyBatisSystemException: There is no getter for property named 'projectId' in 'class java.lang.String'
<select id="list" parameterType="java.lang.String" resultType="java.lang.String">
    select username from user
    <!--錯誤用法,正確用法爲 _parameter-->
    <if test="id != null">
          where id=#{id}
    </if>
</select>

壓測相關

系統的連接端口耗盡

Cause: java.net.NoRouteToHostException: Cannot assign requested address.

前端相關

瀏覽器Long長度大於17會精度丟失,解決辦法是後臺將Long轉爲String,原因是js number的侷限

跨域問題

Http ResponseHeader 中的自定義屬性,如果瀏覽器請求抓包可以看到,但是js中獲取不到,則需要檢查跨域配置

解決: 響應頭Access-Control-Expose-Headers,配置自定義屬性,然後就可以獲取到了。

問題請求:angular1.6 $http.post
原文:http://www.it1352.com/886056.html
參考:跨域資源共享 CORS 詳解


在react中,setState是異步操作,賦值後不能馬上生效。


The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'. 

當看到此錯誤時注意,當前端請求配置credentials: "include"時,後端需要配置"Access-Control-Allow-Credentials"爲true,這樣才能使帶credentials的CORS請求成功。
SpringBoot2.0下對跨域的處理方式可以爲使用@CrossOrigin註解或者編寫配置類實現WebMvcConfigurer接口的addCorsMappings方法。

    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**")
                .allowedHeaders("*")
                .allowedMethods("POST","GET")
                .allowedOrigins("*")
                .allowCredentials(true);
    }

React Eslint 報錯與警告

Do not use setState in componentDidMount
componentDidMount 執行是在DOM渲染完成後,在這裏面使用setState會觸發重繪,相當於進行了兩次渲染,因此建議在constructor或者componentWillMount中把準備工作做好。當然在componentDidMount 週期異步獲取數據並通過setState賦值是正確邏輯。


Arrow function should not return assignment.

<div ref={(el) => { this.myCustomEl = el }} />

在使用箭頭函數的時候,不應當返回賦值語句。


JSX props should not use arrow functions
A bind call or arrow function in a JSX prop will create a brand new function on every single render. This is bad for performance, as it may cause unnecessary re-renders if a brand new function is passed as a prop to a component that uses reference equality check on the prop to determine if it should update.
https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-bind.md


Expected to return a value in arrow function array-callback-return


res操作可能存在異步調用

問題描述:Cannot set headers after they are sent to the client
發生了兩次res的返回,原因可能是因爲存在異步調用,異步後又嘗試使用res.send,將異步方法改爲同步可以解決這個問題。

Linux及生產環境問題

磁盤沒有空間

磁盤沒有空間:Error: ENOSPC: no space left on device, write
解決方案:增大磁盤空間或刪除遷移沒用文件,如日誌文件


Git問題

兩個分支歷史不匹配,無法合併

Could Not Merge origin/sprint2-mjk: refusing to merge unrelated histories
解決辦法:git merge origin/sprint2-mjk --allow-unrelated-histories


Docker問題

resource is denied,需要登錄harbor

denied: requested access to the resource is denied
解決辦法: docker login $harbor --username admin --password $harbor_password

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章