SpringBoot使用Mybatis&Mybatis-plus文件映射配置
心中無女人,出刀自然神。
簡介:Springboot使用Mybatis&Mybatis-plus 兩者文件映射配置略有不同,之前我用的是Mybatis,但公司用Mybatis-plus;自己新建了一個Springboot項目,代碼運行時一直報錯not found not found,明明配置了mybatis相關信息的掃描路徑,但是就是not found;檢查修改了很多地方但都是無用功,最終發現是Plus惹的禍。
1、使用Mybatis
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>1.3.2</version>
</dependency>
yml文件配置的mapper映射及相關信息格式:
mybatis:
mapper-locations: classpath:mybatis/mapper/*.xml
config-locations: classpath:mybatis/mybatis-config.xml
type-aliases-package: com.ausclouds.bdbsec.entity
2、使用Mybatis-Plus
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.2.0</version>
</dependency>
yml文件配置的mapper映射及相關信息格式:
mybatis-plus:
mapper-locations: classpath:mybatis/mapper/*.xml
config-locations: classpath:mybatis/mybatis-config.xml
type-aliases-package: com.example.demo.entity
3、Others
加上@Slf4j 注解后,仍然不能用log直接支配日志,因為沒有安裝Lombok插件。
加上@Data 注解后,仍然不能使用getter/setter,因為沒有安裝Lombok插件。
在類上加注解@AllArgsConstructor 注解可以代替所有@Autowired 注解,就不用在一個類中引入多個@Autowired。
下載前端代碼后需要在控制台運行:npm install,下載前端工程后在控制台npm install 相當於后端的下載jar包,目錄級別還不能亂放,按照git工程代碼格式,不能新建目錄文件,否則資源下不來。
心中無女人
出刀自然神