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

Support auto-configure LanguageDriver provided by MyBatis's sub module #300

Closed
kazuki43zoo opened this issue Mar 9, 2019 · 0 comments · Fixed by #331
Closed

Support auto-configure LanguageDriver provided by MyBatis's sub module #300

kazuki43zoo opened this issue Mar 9, 2019 · 0 comments · Fixed by #331

Comments

@kazuki43zoo
Copy link
Member

kazuki43zoo commented Mar 9, 2019

I consider to support auto-configure for following language drivers.

Specifications

In this change, following specification changes applied.

Auto configuration of language driver bean

Support to configure above three plugin language driver bean when same type bean not present in DI container.

Detecting language driver bean

Support to detect a language driver bean from DI container. You can register any scripting language driver to MyBatis and If target bean count is one, it has been configured to the default scripting language driver.

@Bean
MyLanguageDriver myLanguageDriver() {
  return new MyLanguageDriver();
}

Customization for ThymeleafLanguageDriver

Support to customize a ThymeleafLanguageDriver creating by auto-configure (= detecting a ThymeleafLanguageDriverConfig bean). You can customize it as follow:

@Bean
ThymeleafLanguageDriverConfig thymeleafLanguageDriverConfig() {
  return ThymeleafLanguageDriverConfig.newInstance(c -> {
    // ... customization code
  });
}

Configuration property for default scripting language driver

Support to set a default scripting language driver by configuration property as follow:

mybatis.default-scripting-language-driver=FQCN

About no backward compatibility

Description

In this change, there is no backward compatibility for existing application when the following all conditions are matched (Please be careful when updating).

  • The plugin language driver(mybatis-freemarker,mybatis-velocity, mybatis-thymeleaf) included one in classpath (= used one of plugin language driver)
  • The default scripting language is not plugin language driver(= used built-in language driver(XMLLanguageDriver, RawLanguageDriver) or custom language driver).

If above all conditions are matched, auto-configure of new version set the plugin language driver to default language driver.

Solution for broken backward compatibility

Please set the default scripting language driver using new configuration property(mybatis.default-scripting-language-driver).

e.g.) When you use the XMLLanguageDriver as default language driver

mybatis.default-scripting-language-driver=org.apache.ibatis.scripting.xmltags.XMLLanguageDriver

How to exclude this change

If you want to ignore this change, please set configuration property as follow:

spring.autoconfigure.exclude=org.mybatis.spring.boot.autoconfigure.MybatisLanguageDriverAutoConfiguration

See https://docs.spring.io/spring-boot/docs/2.1.6.RELEASE/reference/htmlsingle/#using-boot-disabling-specific-auto-configuration.

Note

This change depends on mybatis-spring 2.0.2.

Related Links

@kazuki43zoo kazuki43zoo added this to the 2.0.1 milestone Mar 9, 2019
@kazuki43zoo kazuki43zoo changed the title Support auto-configure LanguageDriver provided by sub module Support auto-configure LanguageDriver provided by MyBatis's sub module Mar 9, 2019
@kazuki43zoo kazuki43zoo self-assigned this Mar 9, 2019
@kazuki43zoo kazuki43zoo modified the milestones: 2.0.1, 2.1.0 Mar 30, 2019
kazuki43zoo added a commit that referenced this issue May 2, 2019
Support auto-configure LanguageDriver provided by MyBatis's sub module
kazuki43zoo added a commit that referenced this issue May 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant