畢設期間遇到的一些問題以及解決方法

1. Module is not listed in package.json dependencies

解決方法:你沒有在package.json文件中沒有加入這個組件依賴,加入即可

在分離中有很多api權限的問題需要解決,包括部署後的vue router路由需要在nginx中配置rewrite規則。

2. Can’t resolve ‘sass-loader’ in…錯誤

解決辦法:npm install sass-loader -D
npm install node-sass -D
https://blog.csdn.net/qq_24058693/article/details/80056557

3. SpringBoot跨域問題的解決

出現問題的原因是瀏覽器的同源策略,即協議、端口和域名都要相同,不同的話就是跨域請求

  • 解決方法有jsonp和cors。
  1. 利用 script 標籤可以跨域加載的特性而創造出來的一種非正式的跨域解決方案
    2.在服務端返回時加入允許跨域的請求頭,允許指定域名的跨域訪問。

在後端添加

 @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**")//設置允許跨域的路徑
                .allowedOrigins("*")//設置允許跨域請求的域名
                .allowCredentials(true)//是否允許證書 不再默認開啓
                .allowedMethods("GET", "POST", "PUT", "DELETE")//設置允許的方法
                .maxAge(3600);//跨域允許時間
    }

實現跨域請求時,每次ajax請求都是新的session,導致無法獲取登錄信息,所有的請求都被判定爲未登陸。
axios.defaults.withCredentials =true;

axios的跨域請求方法的封裝

4.崗位怎麼和公司關聯?

1.得先從session中獲取到登錄的公司信息–eName公司名稱(唯一)
2.職位信息表中添加一個招聘公司名稱字段,以此來查詢對應公司的招聘崗位信息。

控制檯報錯

Error starting ApplicationContext. To display the conditions report re-run your application with ‘debug’ enabled.
2019-04-28 12:40:01.482 ERROR 11664 — [ restartedMain] o.s.boot.SpringApplication : Application run failed

@GetMapping(value = “getJobListByFilter”,produces = “application/json; charset=UTF-8”)寫錯了application/json;

5. Result Maps collection does not contain value for com.qtu.zp.domain.JobPositionAndEnterpriseMessage

將resultMap修改成resultType

6.routerrouter和route的區別
  • $router : 是路由操作對象,只寫對象
  • $route : 路由信息對象,只讀對象

produces = "application/json; charset=UTF-8"少了個分號

8.使用axios.delete時後臺接收不到參數

delete 和 post 、put 的參數不一樣,post、put都有三個參數,分別爲url、data還有config,
而delete只有兩個參數,第一個是url,第二個是config

9.Parameter ‘0’ not found. Available parameters are [arg1, arg0, param1

在MyBatis3.4.4版不能直接使用#{0}要使用 #{arg0}

Invalid prop: type check failed for prop “defaultOpeneds”. Expected Array, got String with value “”.

mock.js?ccd5:8359 OPTIONS http://localhost:8082/zp/addBusinessInformation 404
send @ mock.js?ccd5:8359
dispatchXhrRequest @ xhr.js?ec6c:178
xhrAdapter @ xhr.js?ec6c:12
dispatchRequest @ dispatchRequest.js?c4bb:59
Promise.then (async)
request @ Axios.js?5e65:51
Axios.(anonymous function) @ Axios.js?5e65:71
wrap @ bind.js?24ff:9
(anonymous) @ UploadEnterpriseCertification.vue?d5d3:107
(anonymous) @ index.js?a811:1
validate @ index.js?a811:1
(anonymous) @ index.js?a811:1
validate @ index.js?a811:1
submitForm @ UploadEnterpriseCertification.vue?d5d3:98
click @ UploadEnterpriseCertification.vue?2866:220
invokeWithErrorHandling @ vue.esm.js?efeb:1856
invoker @ vue.esm.js?efeb:2178
invokeWithErrorHandling @ vue.esm.js?efeb:1856
Vue.$emit @ vue.esm.js?efeb:3850
handleClick @ index.js?a811:1
invokeWithErrorHandling @ vue.esm.js?efeb:1856
invoker @ vue.esm.js?efeb:2178
original._wrapper @ vue.esm.js?efeb:7503
uploadEnterpriseCertification:1 Access to XMLHttpRequest at ‘http://localhost:8082/zp/addBusinessInformation’ from origin ‘http://localhost:8081’ has been blocked by CORS policy: Response to preflight request doesn’t pass access control check: It does not have HTTP ok status.
多了一個空格

10.Cannot delete or update a parent row: a foreign key constraint fails (zp.business_information, CONSTRAINT business_information_ibfk_1 FOREIGN KEY (eName) REFERENCES enterprise_message (emName))

The error may involve com.qtu.zp.dao.EnterpriseMapper.updateEnterprise-Inline
The error occurred while setting parameters
SQL: UPDATE enterprise_login set eName=?, ecreateTime= ?, status= ? WHERE ephone= ?
Cause: java.sql.SQLIntegrityConstraintViolationException: Cannot delete or update a parent row: a foreign key constraint fails (zp.business_information, CONSTRAINT business_information_ibfk_1 FOREIGN KEY (eName) REFERENCES enterprise_message (emName))
; Cannot delete or update a parent row: a foreign key constraint fails (zp.business_information, CONSTRAINT business_information_ibfk_1 FOREIGN KEY (eName) REFERENCES enterprise_message (emName)); nested exception is java.sql.SQLIntegrityConstraintViolationException: Cannot delete or update a parent row: a foreign key constraint fails (zp.business_information, CONSTRAINT business_information_ibfk_1 FOREIGN KEY (eName) REFERENCES enterprise_message (emName))] with root cause

添加級聯

11後端報錯

.Error:Maven Resources Compiler: Failed to copy ‘G:\dasixia\study_graduation_project\source program\zp\src\main\resources\mapper\recruitmentSituationMapper.xml’ to ‘G:\dasixia\study_graduation_project\source program\zp\target\classes\mapper\recruitmentSituationMapper.xml’: G:\dasixia\study_graduation_project\source program\zp\target\classes\mapper\recruitmentSituationMapper.xml (拒絕訪問。)

id重複

12.java.lang.NullPointerException: null

List candidateResume =new ArrayList(); //=null只是在棧中有一個引用但並沒有分配內存空間
如果這時我直接向orderList裏添加對象就是直接向這個引用所指的內存放東西,因爲沒分配內存,所以會報空指針異常,所以需要把List orderList = nul;改爲

List orderList = new ArrayList();就對了

13. Cannot read property ‘toFixed’ of null

折線圖如果只有一個點就沒辦法渲染

14.訪問本地資源時瀏覽器會報Not allowed to load local resource,後來查詢得知谷歌瀏覽器爲保護安全不允許直接訪問本地資源,然後我就要解決這問題進行訪問這個資源

有兩個解決方案

  • 更改tomcat的server.xml文件就行虛擬地址映射,就能訪問到該資源(數據庫存儲了圖片路徑,每個人的tomcat版本號名不一樣導致文件名也不一樣,根據這個進行修改部署比較麻煩)
    設置項目裏的Server/server.xml,< Host >標籤中加上一行(路徑文件夾後面的’\’可以不加): < Context path=”/test/images” docBase=”c:\images” reloadable=”true”/>
    以後就可以使用 http://localhost/test/images/xxx.png 訪問了
    Springboot內置tomcat設置虛擬目錄
  • 像訪問文件服務器一樣進行資源訪問(要麼就把圖片放進服務器 )
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章