我一直在嘗試學習將 reactJS 前端與 springboot 后端集成。我按照教程構建了一個帶有 reactJS 前端和 spring boot java 后端的演示 CRUD 應用程式。總的來說,我對 react 和 javascript 非常陌生,在 java 方面有更多經驗,而且我在將這兩部分整合在一起時遇到了很多麻煩。react 應用程式位于 springboot 應用程式的檔案結構中。我的 springboot 專案在埠 8080 上運行,react 應用程式在 8081 上運行。我雙方都在“作業”,但是當我嘗試啟動 servlet,然后啟動 react 應用程式時,兩者都開始作業,但我之間沒有通信兩個當我嘗試在 localhost:8081 上打開頁面并操作 UI 時。請幫助一個卑微的 js n00b 解決這個問題,我已經研究了大約一個星期,但沒有任何新成果。
localhost:8080/api/tutorials:1 加載資源失敗:net::ERR_SSL_PROTOCOL_ERROR
有一個看起來像的 axios 錯誤
AxiosError
code: "ERR_NETWORK"
config: {transitional: {…}, transformRequest: Array(1), transformResponse: Array(1), timeout: 0, adapter: ?, …}
message: "Network Error"
name: "AxiosError"
request: XMLHttpRequest {data: undefined, onreadystatechange: null, readyState: 4, timeout: 0, withCredentials: false, …}
response: XMLHttpRequest {data: undefined, onreadystatechange: null, readyState: 4, timeout: 0, withCredentials: false, …}
[[Prototype]]: Error
如果有幫助,這是我遵循的教程。
https://www.bezkoder.com/react-spring-boot-crud/#Create_038_Setup_Spring_Boot_project
這是我擁有所有代碼的 github 存盤庫。 https://github.com/SeanRogan/CrudAppDemo/
前端原始碼:https ://github.com/SeanRogan/CrudAppDemo/tree/master/frontend/src
后端原始碼: https ://github.com/SeanRogan/CrudAppDemo/tree/master/src/main/java/com/seanrogandev/crudapp/demo
pom.xml: https ://github.com/SeanRogan/CrudAppDemo/blob/master/pom.xml
application.properties:https://github.com/SeanRogan/CrudAppDemo/blob/master/src/main/resources/application.properties _
manifest.json: https ://github.com/SeanRogan/CrudAppDemo/blob/master/frontend/public/manifest.json
package.json: https ://github.com/SeanRogan/CrudAppDemo/blob/master/frontend/package.json
如果我遺漏了任何其他相關資訊,請告訴我。提前致謝。
uj5u.com熱心網友回復:
您在后端使用 HTTP,但反應應用程式嘗試使用 HTTPS 訪問。檢查http-common.js
檔案。
baseURL: "https://localhost:8080/api",
更改為 HTTP 應該可以。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/470909.html
標籤:javascript 爪哇 反应 弹簧靴 axios