將陣列中的資料以鍵值對方式新增到物件中
阿新 • • 發佈:2021-02-13
技術標籤:微服務線上教育平臺
在service_base中要使用和它平級的module裡的R.java類 需要現在service_base的pom.xml中引入依賴
<dependencies>
<dependency>
<groupId>com.kaki</groupId>
<artifactId>common_utils</artifactId>
<version>0.0.1-SNAPSHOT</version >
</dependency>
</dependencies>
package com.kaki.servicebase.exceptionhandler;
import com.kaki.commonutils.R;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind. annotation.ResponseBody;
@ControllerAdvice
public class GlobalExceptionHandler {
@ExceptionHandler(Exception.class)//捕獲所有的異常
@ResponseBody//使它能夠返回資料
public R exceptionhandler(Exception e){
e.printStackTrace();
return R.error().message("哦豁,出錯了...已執行全域性異常處理");
}
}
現在service_base裡已經包含了common-utils 則在service模組中只需要引入service_base就可以 不需要兩個都引入
maven的依賴傳遞 否則造成重複引用可能出現一些問題