使用springboot 時contraller中findById 方法報錯問題
在書寫springboot的contraller時 出現了 findById和findOne 報錯出紅。
經過查詢一番資料後,發現spring boot 2版本中所用的查詢是 findById(); 並且在使用的時候會加上一個get()方法
程式碼如下:
@Autowired private UserRepository userRepository; @RequestMapping(value = "/fone/{id}") public User selectOne(@PathVariable("id") Integer id){ User user = new User(); //userRepository.findOne(id); //userRepository.findOne(user); user = userRepository.findById(id).get(); System.out.println(user); return user; }
這樣查詢資料便會成功。
相關推薦
使用springboot 時contraller中findById 方法報錯問題
在書寫springboot的contraller時 出現了 findById和findOne 報錯出紅。 經過查詢一番資料後,發現spring boot 2版本中所用的查詢是 findById(); 並且在使用的時候會加上一個get()方法
傳參時Url中有中文報錯
head 無效 解釋 content uri 就會 invalid ins character url中如果傳了中文,瀏覽器會報錯:The header content contains invalid characters。 原因:瀏覽器自動把這個url進行decodeU
Springboot項目中Pom.xml報錯
xml報錯 pen https idea ID 怎麽 分享 import 項目 摘要:使用idea,兩次在maven上浪費時間,第一次不知道怎麽就解決了,第二次記錄一下解決辦法 情況說明:界面如下圖,pom.xml中存在多個jar,報錯,依賴沒有找到,檢查maven模型以解
maven專案中main方法 報錯
在做一個專案的時候,想要用main方法測試一下 可是總是會報錯 如下 網上也找不到正確的解決方法 最後請教了總監大人 在pom.xml中加入瞭如下程式碼 成功解決 <testOutputDirectory>target/test-classes<
定時器setTimeout/setInterval中變量報錯:not defined 的解決方法
span cor .com ldo href log bug 上下 指正 首先聲明本人資質尚淺,如有錯誤,歡迎指正、共同提高。 -------------------------------------------------------------------------
c# 如果一個對象的值為null,那麽它調用擴展方法時為甚麽不報錯
tro img 數據類型 一個 emp void person () rem 如果一個對象的值為null,那麽它調用擴展方法時會報錯嗎? Person p = null ; p.ExtendMethod(); 上述代碼出現的情況不會報錯,剛開始遇到這種情況時很納悶,就去
解決:oracle+myBatis ResultMap 類型為 map 時返回結果中存在 timestamp 時使用 jackson 轉 json 報錯
得到 了解 strong asn oid style 就是 put ted 前言:最近在做一個通用查詢單表的組件,所以 sql 的寫法就是 select *,然後 resultType="map" ,然後使用 jackson @ResponseBody 返回前端報錯。 轉
SpringBoot 搭建pom檔案parent節點報錯解決方法
剛建立springboot專案,pom檔案parent節點就瘋狂報錯。檢視原因是少了包,但是無論怎麼更新都下載不到,還會一直報錯。 嘗試將打包方式改為pom,雖然能成功執行,但是改為war又會報錯。 maven update時勾選Force Update強行重新下載包也不行,後面索性把庫檔案全部刪
解決C#中呼叫WCF方法報錯:遠端伺服器返回錯誤 (404) 未找到
IIS配置問題,解決方法: 1. 首先新增MIME型別 副檔名“.svc”,MIME型別 “application/octet-stream” 2、處理程式對映--新增託管處理程式 請求路徑 “.svc” 型別 “System.ServiceModel.Activation.HttpH
關於Vivado模擬時出現[XSIM 43-3225] 報錯的解決方法
最近在學習如何模擬Xilinx官方提供的IP核,以DDS IP核為例模擬的時候遇到這樣一個問題 ERROR: [XSIM 43-3225] Cannot find design unit xil_defaultlib.tb_dds_compiler_0 in library work locat
springBoot中引用redis報錯, Consider defining a bean of type 'org.springframework.data.redis.core.RedisTem
我們在springboot中經常引用redis,因為springBoot中自帶了許多起步依賴,我們不要給他加入自己的版本號,要不然很容易造成版本號衝突,導致redis引入不進來,報 Consider defining a bean of type 'org.springfra
Android Studio中寫了一個工具類,進行測試時在Manifest.xml中寫報錯
這是包,utils下的HttpUtils是工具類 在Manifest.xml檔案下寫<instrumentation時報錯,<instrumentation></instrumentation>部分程式碼如下:<instrumentati
hibernate中delete()方法報錯處理方法
@Override public void del(Picture picture) { session.beginTransaction(); System.out.println(picture.getId());
Eclipse安裝lombok,專案中所有get、set方法報錯
Lombok是能自動接通編輯器和構建工具的一個Java庫。最大的特點是不用再一次寫額外的getter或者equals方法。然而專案已經匯入了lombok-1.16.6.jar,仍然報錯,或者說lombok的jar包沒有生效,經過查閱資料才知道,是lombok外掛沒安裝,查詢其官網能看到安裝方
android studio中執行main方法報錯問題解決方法
as3.0中,在專案中新建一個類,無論點選run XXX.main()還是run XXX.main() with coverage,都會報如下的錯: Error:Gradle: failed to create directory 'E:\AndriodStudioProj
無盤伺服器中的磁碟報錯快速定位出錯的硬碟方法
Windows伺服器系統日誌檢視方法方法1:開始選單\執行\cmd\eventvwr.msc方法2:右鍵“計算機”管理\事件檢視器\windows日誌\方法3:開始選單\控制面板\管理工具\事件檢視器磁碟報錯快速定位出錯硬碟方法?系統事件日誌報DISK錯誤,包含如下資訊:\D
Java-Eclipse匯入maven專案時,Pom.xml檔案報錯處理方法
匯入maven專案,FIle→Import→Existing Maven Projects→找到自己想要匯入的檔案目錄→Finish。專案就匯入完成啦。接著就遇上了各種報錯!!一、Pom.xml檔案第一次報錯CoreException: Could not get the
eclipse專案中request.getLocalPort()方法報錯:
eclipse專案編譯報錯The method getLocalPort() is undefined for the type HttpServletRequest 原因及解決辦法: j2ee.jar包中的servlet版本或者是jboss中的servle
在git下載的原始碼執行時因為cocopods第三方庫報錯的解決方法
很多新手在git上下載專案的原始碼到本地,開啟工程之後執行會報錯,原因是無法找到第三方庫。出現這種問題時,開啟工程目錄,如果看到podfile檔案,那麼此專案的第三方庫就是用cocopods進行管理的,那麼在使用的時候需要進行本地更新。 首先你的
Eclipse中啟動tomcat報錯java.lang.OutOfMemoryError: PermGen space的解決方法
最近在熟悉一個開發了有幾年的專案,需要把資料庫從mysql移植到oracle,首先把jdbc的連線指向mysql,打包放到tomcat裡面,可以跑起來,沒有問題,可是當把jdbc連線指向oracle的時候,tomcat就連續拋java.lang.OutOfMemoryError的錯誤,上網google了一下,