Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SqlSessionFactoryBean single resource, using wildcard causes a IOException #792

Open
JuHyun419 opened this issue Mar 17, 2023 · 4 comments · May be fixed by #802
Open

SqlSessionFactoryBean single resource, using wildcard causes a IOException #792

JuHyun419 opened this issue Mar 17, 2023 · 4 comments · May be fixed by #802

Comments

@JuHyun419
Copy link

image

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'

image


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());
  }

image


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());
  }

image

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?

@sarswat001
Copy link

Hi,
Task here is to add comment for setMapperLocations() and also add JUnits for this?

@hazendaz
Copy link
Member

Hi @sarswat001, sounds reasonable to assist users, feel free to raise PR for same and we can take a look at it. Thanks.

@sarswat001
Copy link

Hi,
Will this not get merged?

@hazendaz
Copy link
Member

hazendaz commented Apr 22, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants