Jry*_*Jry 2 spring mybatis spring-boot spring-mybatis
我正在开发一个使用 mybatis 的 spring boot 应用程序。我的 mybatis mapper xml 有一个 SQL 查询,其中包含需要从应用程序属性设置的数据库模式名称。我有一个架构名称,我想在我的mapper.xml${schema-name} 中引用它。我可以这样做mybatis-config.xml- 像这样:
<configuration>
<PropertiesSource url='my properties file"/>
<properties>
<property name='schema-name' value='${database.schema}'/>
</properties>
</configuration>
Run Code Online (Sandbox Code Playgroud)
但我不想使用mybatis-config.xml. 我想使用spring bootapplication.properties进行mybatis配置。
有没有办法在spring boot application.properties中设置mybatis配置属性?有人可以帮我弄这个吗?
如果使用mybatis-spring-boot-starter 1.2.0,可以指定如下:
mybatis.configuration-properties.schema-name=abc
Run Code Online (Sandbox Code Playgroud)
或者
mybatis.configuration.variables.schema-name=abc
Run Code Online (Sandbox Code Playgroud)如果您使用mybatis-spring-boot-starter 1.1.1,则可以指定如下:
mybatis.configuration.variables.schema-name=abc
Run Code Online (Sandbox Code Playgroud)如果使用mybatis-spring-boot-starter 1.0.x,则无法在application.properties上指定。(请更新至1.1.1+)
请尝试一下。
谢谢。
| 归档时间: |
|
| 查看次数: |
5838 次 |
| 最近记录: |