I am trying to running some unit test cases that need to read spring xml configurations under Intellij, but Intellij failed with the following error.
org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [test.xml]; nested exception is java.io.FileNotFoundException: class path resource [test.xml] cannot be opened because it does not exist
Under Intellij, my folder structure is:
src/main/java
src/main/test
src/main/spring
and text.xml file is under src/main/spring
The related java code that loads configuration file is:
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("test.xml")
I have searched for several posts and I have tried the following ways:
1) marked src/main/spring folder as "sources" or "resources".
2) added src/main/spring as a module under project structure.
but unfortunately, none of them is working.
My sourceSets in build.gradle setting is:
sourceSets {
main {
java {
srcDir 'src/main/java'
}
proto {
// In addition to the default "src/main/proto"
srcDir "src/main/proto"
}
}
test {
java {
srcDir 'src/main/test'
}
proto {
srcDir "src/main/proto"
}
}
}
I am a newbie to Gradle and hopefully someone could give me a hint. Really appreciate!