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
Activity
sarswat001 commentedon Apr 15, 2023
Hi,
Task here is to add comment for setMapperLocations() and also add JUnits for this?
hazendaz commentedon Apr 15, 2023
Hi @sarswat001, sounds reasonable to assist users, feel free to raise PR for same and we can take a look at it. Thanks.
sarswat001 commentedon Apr 22, 2023
Hi,
Will this not get merged?
hazendaz commentedon Apr 22, 2023