Skip to content

Configuration

Integrating MyBatis-Plus is extremely simple! We only need some basic configuration to utilize the powerful features of MyBatis-Plus.

Spring Boot Project

  • Configure the MapperScan annotation

    @SpringBootApplication
    @MapperScan("com.baomidou.mybatisplus.samples.quickstart.mapper")
    public class Application {
    public static void main(String[] args) {
    SpringApplication.run(Application.class, args);
    }
    }

Spring Project

  • Configure MapperScan

    <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
    <property name="basePackage" value="com.baomidou.mybatisplus.samples.quickstart.mapper"/>
    </bean>
  • Adjust SqlSessionFactory to MyBatis-Plus’s SqlSessionFactory

    <bean id="sqlSessionFactory" class="com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean">
    <property name="dataSource" ref="dataSource"/>
    </bean>

Generally, for simple projects, the above configurations are sufficient to use MyBatis-Plus normally. You can refer to the following sample projects: Spring Boot Quick Start Example, Spring MVC Quick Start Example.

Additionally, MyBatis-Plus provides extensive customization options to meet the needs of projects with varying complexity. You can select configurations as needed for your project. For detailed configurations, refer to the Configuration Reference article.

For complex table structures, we also offer a rich set of field annotations to address special requirements. For details, refer to the Annotations article.

Baomidou

© 2016-2025 Baomidou™. All Rights Reserved.

Power by Astro Starlight | Sponsored by JetBrains

渝ICP备2021000141号-1 | 渝公网安备50011302222097