1. 程式人生 > >nested exception is org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)

nested exception is org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)

開始用IDEA以後經常出現以前從來沒有出現過的問題,這不今天又出了一個,報錯資訊如下圖

報錯資訊告訴我沒有辦法找到com.demo.mapper包下UserMapper對映的queryUserbyphonenumber這個方法,我檢查了了一下是不是呼叫的方法名稱或者namespace寫錯了,但是都沒有問題,所以我想了一下是不是因為這個xml檔案沒有被編譯或者別加載,於是我到target資料夾下看了一下,如下圖,果然這個classes的包裡沒有xml檔案

後來上網找了一下,應該要在pom檔案裡面加上這麼一段,就不會再報錯了

 <resources>           
      <resource>                
        <directory>src/main/java</directory>                
        <includes>                    
          <include>**/*.properties</include>                    
          <include>**/*.xml</include>                
        </includes>                
        <filtering>false</filtering>           
      </resource>        
    </resources>

這樣就可以解決不build  xml檔案的問題了

記錄下來,以防止以後再次遇到這個問題又忘記了