導包
<!--mybatis-plus start-->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.1.0</version>
</dependency>
<!-- mybatis-plus自動模闆引擎依賴 -->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-generator</artifactId>
<version>3.1.0</version>
</dependency>
<!-- mybatis-plus需要的模闆引擎freemarker -->
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
</dependency>
<!--mybatis-plus end-->
yml配置
mybatis-plus:
configuration:
#配置傳回資料庫(column下劃線命名&&傳回java實體是駝峰命名),自動比對無需as(沒開啟這個,SQL需要寫as: select user_id as userId)
map-underscore-to-camel-case: true
cache-enabled: false
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl #列印sql語句,調試用
bean 配置
/**
* 分頁插件
*/
@Bean
public PaginationInterceptor paginationInterceptor() {
return new PaginationInterceptor();
}
/**
* 格式化列印 sql
*/
@Bean
public PerformanceInterceptor performanceInterceptor() {
PerformanceInterceptor performanceInterceptor = new PerformanceInterceptor();
//格式化sql語句
Properties properties = new Properties();
properties.setProperty("format", "true");
performanceInterceptor.setProperties(properties);
return performanceInterceptor;
}
xml 編寫大于等于,小于等于,出現報錯的解決辦法
由于在mybatis架構的xml中<= , >=解析會出現問題,編譯報錯,是以需要轉譯
第一種寫法:
原符号
< <= > >= & ’ "
替換符号
< <= > >= & ' "
詳細表:
原符号 | 替換符号 |
---|---|
< | |
<= | |
>= | |
& | |
’ | |
" | |
例如:sql如下:
第二種寫法:
大于等于
小于等于
例如:sql如下: