Open
Description
I saw the setMapperLocations method comment in the SqlSessionFactoryBean class and set up Resource using wildcard, but the following exception occurred:
java.io.IOException: Failed to parse mapping resource: 'class path resource'
If you use the getResource() method that returns a single resource, an exception occurs when using wildcards.
The relevant test codes are as follows:
(I added this test code to the SqlSessionFactoryBeanTest class)
@Test
void testSingleResourceWildcardMapperLocationsShouldThrowException() {
setupFactoryBean();
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
Resource resource = resolver.getResource("classpath*:org/mybatis/spring/*Mapper.xml");
factoryBean.setMapperLocations(resource);
assertThrows(IOException.class, () -> factoryBean.getObject());
}
If you use `getResources()`, there are no exceptions when you use wildcard.
@Test
void testMultiResourceMapperLocations() throws Exception {
setupFactoryBean();
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
Resource[] resource = resolver.getResources("classpath*:org/mybatis/spring/*Mapper.xml");
factoryBean.setMapperLocations(resource);
assertNotNull(factoryBean.getObject());
}
So, Why don't you add a description of this exception information in the comments of the setMapperLocations method?
And is it okay to add this test code?
Metadata
Metadata
Assignees
Labels
No labels