1

I'm develop some Spring boot applications accessing DB using Mybatis starter.

I'm trying to split xml mapper files to external location like project root (when dev env), or jar-located directory (when prod env).

I change some options on application.properties like mybatis.mapper-locations to

  • ./mappers/**/*.xml
  • file:///./mappers/**/*.xml

But these relative directory settings didn't work. And absolute directory is works.

  • file:///full/paths/to/project/mappers/**/*.xml

But I want to run with relative path. Because once set it relative, no need to change directory settings every deploy path changes!

There's no way to resolve this issue?

  • I test the classpath setting, It didn't work and It looks not clean way...
  • It's unclear why you want to manage XML mappers like that, but you may be able to use a variable like `${myMapperLocation}` in the config and specify the actual path as an environment variable. – ave Jun 13 '20 at 16:25
  • @ave Thanks to reply! I've resolve that problem to create shell script. The script are obtaining working absolute directory, and set Spring boot run argument 'mybastis.mapper-locations'! – Choryu Park Jun 13 '20 at 18:32

0 Answers0