IDEA mapper 報錯:Invalid bound statement (not found)

拋開mybatis bing 問題不談,很有可能是

target 路徑下mapper.xml未編譯。解決:在pom.xml添加

<resources>
            <!-- maven項目中src源代碼下的xml等資源文件編譯進classes文件夾,
              注意:如果沒有這個,它會自動搜索resources下是否有mapper.xml文件,
              如果沒有就會報org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.pet.mapper.PetMapper.selectByPrimaryKey-->
            <resource>
                <directory>src/main/java</directory>
                <includes>
                    <include>**/*.xml</include>
                </includes>
            </resource>

            <!--將resources目錄下的配置文件編譯進classes文件  -->
            <resource>
                <directory>src/main/resources</directory>
            </resource>

        </resources>

然後搞定!

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章