Skip to content

Commit 2559280

Browse files
committed
add: config page
1 parent 10e1492 commit 2559280

File tree

1 file changed

+45
-1
lines changed

1 file changed

+45
-1
lines changed

en/guide/config.md

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,45 @@
1-
# Config
1+
# Configuration
2+
3+
Configuration for MyBatis-Plus is so easy, we just need a few configurations so that can have powerful functions.
4+
5+
::: tip
6+
Make sure you have installed MP. If not, please refer to [Install](install.md)
7+
:::
8+
9+
- Spring Boot Structure:
10+
11+
- Configure MapperScan Annotation
12+
13+
```java {2}
14+
@SpringBootApplication
15+
@MapperScan("com.baomidou.mybatisplus.samples.quickstart.mapper")
16+
public class Application {
17+
18+
public static void main(String[] args) {
19+
SpringApplication.run(QuickStartApplication.class, args);
20+
}
21+
22+
}
23+
```
24+
25+
- Spring MVC Structure
26+
27+
- Configure `MapperScan` in application.xml
28+
29+
```xml {2}
30+
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
31+
<property name="basePackage" value="com.baomidou.mybatisplus.samples.quickstart.mapper"/>
32+
</bean>
33+
```
34+
35+
- Change SqlSessionFactory to `MybatisSqlSessionFactoryBean` of MP
36+
37+
```xml {1}
38+
<bean id="sqlSessionFactory" class="com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean">
39+
<property name="dataSource" ref="dataSource"/>
40+
</bean>
41+
```
42+
43+
General speaking, for general projects, we can use MP just for configurations above. You also can refer to [Spring Boot Quick Start](https://github.com/baomidou/mybatis-plus-samples/tree/master/mybatis-plus-sample-quickstart)
44+
45+
BTW, MP provides a lot of customized configurations to meet different needs. Refer to [Configurations](../config/README.md)

0 commit comments

Comments
 (0)