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

報錯:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):

報錯:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):

報錯資訊如下,
在這裡插入圖片描述
頁面報錯:
在這裡插入圖片描述
主要原因是:target裡面.xml檔案沒有編譯出來;
我導致這個原因是因為誤刪除了resources裡面的com.pinyougou.mapper;導致編譯不出的.xml檔案,
報這個錯是因為:maven專案中src原始碼下的xml等資原始檔編譯進classes資料夾,
它會自動搜尋resources下是否有mapper.xml檔案,如果沒有就會報:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):

如果有卻無法掃描*Mapper.xml檔案,同時無法將配置檔案載入到classes:
在pom.xml中加入如下配置:

 <build>
    <resources>  

      <resource>  
        <directory>src/main/java</directory>  
        <includes>  
          <include>**/*.xml</include>  
        </includes>  
      </resource>
      
      <!--將resources目錄下的配置檔案編譯進classes檔案  -->  
      <resource>
			<directory>src/main/resources</directory>
	  </resource>
    </resources>  
  </build>