Skip to content

Output a warning log when 'mapperLocations' was specified but matching resources are not found #12

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

Closed
lmiroslaw opened this issue Jun 19, 2013 · 4 comments
Assignees
Labels
enhancement Improve a feature or add a new feature
Milestone

Comments

@lmiroslaw
Copy link

I found out someting interesting. mapperLocations property in my xml configuration file points to non-existing path:

 <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
    <property name="dataSource" ref="dataSource"/>
    <property name="typeAliasesPackage" value="com.ucware.ucpo.statemachine.model"/> <!-- Register the short names of beans as aliases -->
    <property name="configLocation" value="classpath:mybatis-config.xml"/>
    <property name="mapperLocations" value="classpath*:/com/state/persistence/mapper/*.xml" />
</bean>

Still org.mybatis.spring.SqlSessionFactoryBean reports no exception.
this.mapperLocations is empty and execution continues.

In my case the correct link to the mapper is:
classpath_:/com/missing_entry/state/persistence/mapper/_.xml

Should not the exception be thrown ?

I use mybatis-spring.1.2.0.

@emacarron
Copy link
Member

Sorry but it is not clear to me that in case you use a mapperLocation property the search should get at least one result.

Getting zero results is indeed suspicious. It looks like a mistake but we cannot be 100% sure that it is a mistake.

@lmiroslaw
Copy link
Author

That's true. It turned out my xml missed the definition of the . This is a reason why was empty. However, it would be nice to see this error in the log as it takes some time to figure it out.

@emacarron emacarron reopened this Jun 24, 2013
@emacarron
Copy link
Member

You are right. I will add a warning for that.

@kazuki43zoo kazuki43zoo added this to the 2.0.1 milestone Apr 5, 2019
@kazuki43zoo kazuki43zoo self-assigned this Apr 5, 2019
@kazuki43zoo
Copy link
Member

I've fixed this issue.
Change to output a warning log when 'mapperLocations' was specified but matching resources are not found. If you want to prevent a warning log on production environment, please change log level of SqlSessionFactoryBean to error or higher.

@kazuki43zoo kazuki43zoo changed the title MapperLocations property contains invalid url and no exception is thrown output a warning log when 'mapperLocations' was specified but matching resources are not found Apr 5, 2019
@kazuki43zoo kazuki43zoo changed the title output a warning log when 'mapperLocations' was specified but matching resources are not found Output a warning log when 'mapperLocations' was specified but matching resources are not found Apr 5, 2019
pulllock pushed a commit to pulllock/mybatis-spring that referenced this issue Oct 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improve a feature or add a new feature
Projects
None yet
Development

No branches or pull requests

3 participants