springboot加载mybatis配置文件

1、maven

	<properties>
		<snakeyaml.version>1.23</snakeyaml.version>
	</properties>
	
	<dependency>
		<groupId>org.yaml</groupId>
		<artifactId>snakeyaml</artifactId>
		<version>${snakeyaml.version}</version>
	</dependency>

2、文件结构
springboot加载mybatis配置文件_第1张图片
3、application.yml内容案例

mybatis:
  mapper-locations: classpath:mapper/*.xml  #注意:一定要对应mapper映射xml文件的所在路径
  type-aliases-package: ${package}.*.domain  # 注意:对应实体类的路径

4、启动类

@MapperScan({"com.dao","com.test.dao"})

5、实体类举例(不需要添加@Repository)

package com.*.domain;
public class Test implements Serializable {
    private static final long serialVersionUID = 1L;
    private Long id;
 }

你可能感兴趣的:(springboot,后端)