You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
src
main
java
mypackage
Main.java
module-info.java // just basic module declaration
resources
config
valid-mybatis-config.xml
Steps to reproduce
public class Main{
public static void main(String[] args) {
try{
Reader r = Resources.getResourceAsReader("config/valid-mybatis-config.xml");
print("reads the resource when file "module-info.java" is absent");
} catch (IOException e){
print("throws and comes here when runs in java module, i.e. "module-info.java" is present");
}
}
}
Expected result
Reads configuration files of myBatis from "resources"
Actual result
Fails with IOException and causes other exceptions related to reading XML resources (config and mappers).
java.io.IOException: Could not find resource config/valid-mybatis-config.xml
at org.mybatis@3.5.7/org.apache.ibatis.io.Resources.getResourceAsStream(Resources.java:114)
at org.mybatis@3.5.7/org.apache.ibatis.io.Resources.getResourceAsStream(Resources.java:100)
at org.mybatis@3.5.7/org.apache.ibatis.io.Resources.getResourceAsReader(Resources.java:160)
at my.sample.module/my.sample.module.mypackage.Main.main(Main.java:11)
Hint
Resources.getResourceAsReader relies on ClassLoader.getResourceAsStream, which cannot find resources in module. Please, consider using Class.getResourceAsStream and Module.getResourceAsStream or provide an API so that user could read XML resources in a named module.
The text was updated successfully, but these errors were encountered:
Thank you @harawata. Tried 3.5.7 and updated the description with full stack trace.
Have checked code in org.apache.ibatis.io.Resources: no significant between 3.5.4 and 3.5.7
MyBatis version
3.5.7
Database vendor and version
any
Test case or example project
Minimal Maven project
Steps to reproduce
Expected result
Reads configuration files of myBatis from "resources"
Actual result
Fails with IOException and causes other exceptions related to reading XML resources (config and mappers).
Hint
Resources.getResourceAsReader
relies onClassLoader.getResourceAsStream
, which cannot find resources in module. Please, consider usingClass.getResourceAsStream
andModule.getResourceAsStream
or provide an API so that user could read XML resources in a named module.The text was updated successfully, but these errors were encountered: