2015年4月2日 星期四

再一次Mybatis出現 java.io.IOException: Could not find resource...使用Gradle

參考:
MyBatis loading XML : java.io.IOException: Could not find resource


又再一次出現了惱人的錯誤:
 java.io.IOException: Could not find resource...


這次的情況很詭異,使用eclipse  build的時候一切成功,但是一使用gradle build就出錯了,跟以前不同的是這次build tool改使用了gradle(之前使用ANT或根本沒用)

找到了以上的參考文章,以下的回答:


Note Since you have placed batisConfig.xml under src/main/java. By default maven configures to include only */*.java file( only java files) if need to include all the files you need to configure accordingly. But I would recommend to move the xml file to src/main/resources directory( which is again a classpath)

雖然我並非使用maven,但是其實是一樣的問題,原來預設於src/main/java下都只有include *.java,因此我只要將我的 mapper.xml 移動到 src/main/resources 就可以囉!