### MyBatis configuration in application.yml Source: https://mybatis.org/spring-boot-starter/mybatis-spring-boot-autoconfigure/index.html Example of setting MyBatis properties in application.yml, with nested configuration keys for map-underscore-to-camel-case, default-fetch-size, and default-statement-timeout. ```yaml # application.yml mybatis: type-aliases-package: com.example.domain.model type-handlers-package: com.example.typehandler configuration: map-underscore-to-camel-case: true default-fetch-size: 100 default-statement-timeout: 30 ... ``` -------------------------------- ### MyBatis configuration in application.properties Source: https://mybatis.org/spring-boot-starter/mybatis-spring-boot-autoconfigure/index.html Example of setting MyBatis properties in application.properties, including type aliases, type handlers, and configuration settings like map-underscore-to-camel-case. ```properties # application.properties mybatis.type-aliases-package=com.example.domain.model mybatis.type-handlers-package=com.example.typehandler mybatis.configuration.map-underscore-to-camel-case=true mybatis.configuration.default-fetch-size=100 mybatis.configuration.default-statement-timeout=30 ... ``` -------------------------------- ### list(URL url, String path) Source: https://mybatis.org/spring-boot-starter/mybatis-spring-boot-autoconfigure/apidocs/org/mybatis/spring/boot/autoconfigure/SpringBootVFS.html Lists the resources at the given URL and path. This method is specified by the org.apache.ibatis.io.VFS class. ```APIDOC ## list(URL url, String path) ### Description Lists the resources at the given URL and path. This method is specified by the org.apache.ibatis.io.VFS class. ### Method list ### Signature `protected List list(URL url, String path) throws IOException` ### Parameters - **url** (URL) - Required - The URL to list resources from. - **path** (String) - Required - The path within the URL to list. ### Returns `List` - A list of resource names found at the given URL and path. ### Throws - `IOException` - If an I/O error occurs. ``` -------------------------------- ### Using @MybatisTest with @ExtendWith(SpringExtension.class) Source: https://mybatis.org/spring-boot-starter/mybatis-spring-boot-test-autoconfigure/index.html Example of using @MybatisTest with JUnit 5, explicitly adding @ExtendWith(SpringExtension.class). This is the standard setup before version 2.0.1. ```java @ExtendWith(SpringExtension.class) @MybatisTest public class CityMapperTest { // ... } ``` -------------------------------- ### CoreConfiguration() Source: https://mybatis.org/spring-boot-starter/mybatis-spring-boot-autoconfigure/apidocs/org/mybatis/spring/boot/autoconfigure/MybatisProperties.CoreConfiguration.html Public constructor for the CoreConfiguration class. ```APIDOC ## CoreConfiguration() ### Description Public constructor for the CoreConfiguration class. ### Method Constructor ### Signature `public CoreConfiguration()` ``` -------------------------------- ### list(URL url, String path) Source: https://mybatis.org/spring-boot-starter/mybatis-spring-boot-autoconfigure/apidocs/org/mybatis/spring/boot/autoconfigure/SpringBootVFS.html Lists resources at the given URL and path. ```APIDOC ## list(URL url, String path) ### Description Lists resources at the given URL and path. ### Method Instance Method ### Signature `protected List list(URL url, String path)` ### Parameters - **url** (URL) - Required - The URL to list resources from. - **path** (String) - Required - The path to list resources from. ### Returns - **List** - A list of resource names found at the given URL and path. ``` -------------------------------- ### Inject SqlSession into a Spring bean (CityDao) Source: https://mybatis.org/spring-boot-starter/mybatis-spring-boot-autoconfigure/index.html Use this snippet to inject a SqlSession (SqlSessionTemplate) into a Spring bean via constructor injection (available on Spring 4.3+). The example shows a CityDao that uses the injected SqlSession to call selectOne with a statement ID. ```java @Component public class CityDao { private final SqlSession sqlSession; public CityDao(SqlSession sqlSession) { this.sqlSession = sqlSession; } public City selectCityById(long id) { return this.sqlSession.selectOne("selectCityById", id); } } ``` -------------------------------- ### Browse source repository on GitHub Source: https://mybatis.org/spring-boot-starter/mybatis-spring-boot-autoconfigure/scm.html Provides a URL to browse the source repository in a web browser. ```text https://github.com/mybatis/spring-boot-starter/mybatis-spring-boot-autoconfigure/ ``` -------------------------------- ### Add Maven dependency for mybatis-spring-boot-starter-test Source: https://mybatis.org/spring-boot-starter/mybatis-spring-boot-test-autoconfigure/index.html Add this dependency to your pom.xml to use the MyBatis-Spring-Boot-Starter-Test module. The version 4.0.0 is specified and the scope is test. ```xml org.mybatis.spring.boot mybatis-spring-boot-starter-test 4.0.0 test ``` -------------------------------- ### SpringBootVFS() Source: https://mybatis.org/spring-boot-starter/mybatis-spring-boot-autoconfigure/apidocs/org/mybatis/spring/boot/autoconfigure/SpringBootVFS.html Constructor for the SpringBootVFS class. ```APIDOC ## SpringBootVFS() ### Description Constructor for the SpringBootVFS class. ### Method Constructor ### Signature `public SpringBootVFS()` ### Parameters None ### Returns A new instance of SpringBootVFS. ``` -------------------------------- ### Register MyBatis components (Interceptor, TypeHandler, LanguageDriver, DatabaseIdProvider) Source: https://mybatis.org/spring-boot-starter/mybatis-spring-boot-autoconfigure/index.html Configuration class that defines beans for MyBatis components. The starter detects these beans automatically. Note: if only one LanguageDriver is detected, it is set as the default scripting language. ```java @Configuration public class MyBatisConfig { @Bean MyInterceptor myInterceptor() { return MyInterceptor(); } @Bean MyTypeHandler myTypeHandler() { return MyTypeHandler(); } @Bean MyLanguageDriver myLanguageDriver() { return MyLanguageDriver(); } @Bean VendorDatabaseIdProvider databaseIdProvider() { VendorDatabaseIdProvider databaseIdProvider = new VendorDatabaseIdProvider(); Properties properties = new Properties(); properties.put("SQL Server", "sqlserver"); properties.put("DB2", "db2"); properties.put("H2", "h2"); databaseIdProvider.setProperties(properties); return databaseIdProvider; } } ``` -------------------------------- ### getConfiguration Source: https://mybatis.org/spring-boot-starter/mybatis-spring-boot-autoconfigure/apidocs/org/mybatis/spring/boot/autoconfigure/MybatisProperties.html Returns the core MyBatis configuration object. ```APIDOC ## getConfiguration ### Description Returns the core MyBatis configuration object. ### Method getConfiguration ### Signature public MybatisProperties.CoreConfiguration getConfiguration() ### Returns - **MybatisProperties.CoreConfiguration** - The core configuration object. ``` -------------------------------- ### getVfsImpl() Source: https://mybatis.org/spring-boot-starter/mybatis-spring-boot-autoconfigure/apidocs/org/mybatis/spring/boot/autoconfigure/MybatisProperties.CoreConfiguration.html Returns the VFS implementation class used by MyBatis. ```APIDOC ## getVfsImpl() ### Description Returns the VFS implementation class used by MyBatis. ### Method GET ### Endpoint MybatisProperties.CoreConfiguration#getVfsImpl() ### Returns - **Class** - The VFS implementation class. ``` -------------------------------- ### protected List list(URL url, String path) Source: https://mybatis.org/spring-boot-starter/mybatis-spring-boot-autoconfigure/zh_CN/apidocs/org/mybatis/spring/boot/autoconfigure/SpringBootVFS.html Lists resources in the given URL and path. ```APIDOC ## protected List list(URL url, String path) ### Description Lists resources in the given URL and path. ### Method Instance method ### Signature `protected List list(URL url, String path)` ### Parameters - **url** (URL) - Required - The URL to list resources from. - **path** (String) - Required - The path within the URL. ### Returns - **List** - A list of resource names. ``` -------------------------------- ### setConfiguration(MybatisProperties.CoreConfiguration) Source: https://mybatis.org/spring-boot-starter/mybatis-spring-boot-autoconfigure/apidocs/index-all.html Sets the MyBatis core configuration. ```APIDOC ## setConfiguration(MybatisProperties.CoreConfiguration) ### Description Sets the MyBatis core configuration. ### Method setConfiguration ### Parameters - **configuration** (MybatisProperties.CoreConfiguration) - Required - The core configuration. ### Returns void ``` -------------------------------- ### SpringBootVFS() Source: https://mybatis.org/spring-boot-starter/mybatis-spring-boot-autoconfigure/apidocs/org/mybatis/spring/boot/autoconfigure/SpringBootVFS.html Constructor for the SpringBootVFS class. Creates a new instance of SpringBootVFS. ```APIDOC ## SpringBootVFS() ### Description Constructor for the SpringBootVFS class. ### Method Constructor ### Signature `public SpringBootVFS()` ### Parameters None ### Returns A new instance of SpringBootVFS. ``` -------------------------------- ### getLogPrefix() Source: https://mybatis.org/spring-boot-starter/mybatis-spring-boot-autoconfigure/zh_CN/apidocs/org/mybatis/spring/boot/autoconfigure/MybatisProperties.CoreConfiguration.html Returns the log prefix. ```APIDOC ## getLogPrefix() ### Description Returns the log prefix. ### Method GET ### Endpoint MybatisProperties.CoreConfiguration#getLogPrefix() ### Returns - **String** - The log prefix. ``` -------------------------------- ### getLogImpl() Source: https://mybatis.org/spring-boot-starter/mybatis-spring-boot-autoconfigure/apidocs/org/mybatis/spring/boot/autoconfigure/MybatisProperties.CoreConfiguration.html Returns the logging implementation class. ```APIDOC ## getLogImpl() ### Description Returns the logging implementation class. ### Method GET ### Endpoint MybatisProperties.CoreConfiguration#getLogImpl() ### Returns - **Type**: Class - **Description**: The logging implementation class. ``` -------------------------------- ### Browsable repository URL Source: https://mybatis.org/spring-boot-starter/mybatis-spring-boot-test-autoconfigure/scm.html URL for browsing the source repository in a web browser. ```text https://github.com/mybatis/spring-boot-starter/mybatis-spring-boot-test-autoconfigure/ ``` -------------------------------- ### Add Gradle dependency for mybatis-spring-boot-starter-test Source: https://mybatis.org/spring-boot-starter/mybatis-spring-boot-test-autoconfigure/index.html Add this dependency to your build.gradle to use the MyBatis-Spring-Boot-Starter-Test module. The version 4.0.0 is specified with testImplementation configuration. ```groovy dependencies { testImplementation("org.mybatis.spring.boot:mybatis-spring-boot-starter-test:4.0.0") } ``` -------------------------------- ### Add Maven dependency for mybatis-spring-boot-starter Source: https://mybatis.org/spring-boot-starter/mybatis-spring-boot-autoconfigure/index.html Add this dependency to your pom.xml to use MyBatis-Spring-Boot-Starter with Maven. The version shown is 4.0.0. ```xml org.mybatis.spring.boot mybatis-spring-boot-starter 4.0.0 ``` -------------------------------- ### MybatisProperties.CoreConfiguration() Source: https://mybatis.org/spring-boot-starter/mybatis-spring-boot-autoconfigure/apidocs/index-all.html Constructor for the CoreConfiguration class, which is a nested class within MybatisProperties. It is used to instantiate a CoreConfiguration object. ```APIDOC ## MybatisProperties.CoreConfiguration() ### Description Constructor for class `org.mybatis.spring.boot.autoconfigure.MybatisProperties.CoreConfiguration`. This constructor is used to create a new instance of the `CoreConfiguration` class. ### Method Constructor ### Signature `CoreConfiguration()` ### Parameters None ### Returns A new instance of `CoreConfiguration`. ### Class `org.mybatis.spring.boot.autoconfigure.MybatisProperties.CoreConfiguration` ``` -------------------------------- ### setLogPrefix(String logPrefix) Source: https://mybatis.org/spring-boot-starter/mybatis-spring-boot-autoconfigure/apidocs/org/mybatis/spring/boot/autoconfigure/MybatisProperties.CoreConfiguration.html Sets the log prefix for MyBatis logging. ```APIDOC ## setLogPrefix(String logPrefix) ### Description Sets the log prefix for MyBatis logging. ### Method setLogPrefix ### Parameters - **logPrefix** (String) - Required - The log prefix. ### Returns void ``` -------------------------------- ### sqlSessionTemplate(SqlSessionFactory) Source: https://mybatis.org/spring-boot-starter/mybatis-spring-boot-autoconfigure/apidocs/index-all.html Creates a SqlSessionTemplate bean using the provided SqlSessionFactory. This method is part of the MybatisAutoConfiguration class. ```APIDOC ## sqlSessionTemplate(SqlSessionFactory) ### Description Creates a SqlSessionTemplate bean using the provided SqlSessionFactory. ### Method sqlSessionTemplate ### Parameters - **sqlSessionFactory** (SqlSessionFactory) - Required - The SqlSessionFactory to use. ### Returns SqlSessionTemplate ``` -------------------------------- ### getLogImpl() Source: https://mybatis.org/spring-boot-starter/mybatis-spring-boot-autoconfigure/zh_CN/apidocs/index-all.html Returns the log implementation class configured in MyBatis properties. ```APIDOC ## getLogImpl() ### Description Returns the log implementation class configured in MyBatis properties. ### Method GET ### Endpoint org.mybatis.spring.boot.autoconfigure.MybatisProperties.CoreConfiguration#getLogImpl() ### Parameters None ### Response - **Returns** (Class) - The log implementation class. ``` -------------------------------- ### setConfigurationFactory(Class) Source: https://mybatis.org/spring-boot-starter/mybatis-spring-boot-autoconfigure/apidocs/index-all.html Sets the configuration factory class. ```APIDOC ## setConfigurationFactory(Class) ### Description Sets the configuration factory class. ### Method setConfigurationFactory ### Parameters - **configurationFactory** (Class) - Required - The configuration factory class. ### Returns void ```