依赖包
org.mybatis.spring.boot mybatis-spring-boot-starter2.1.3
properties配置
#指定xml文件的路径。*是个通配符,代表所有的文件,**代表所有目录下 mybatis.mapperLocations=classpath:mybatis/*Mapper.xml #开启控制台sql语句打印 mybatis.configuration.log-impl=org.apache.ibatis.logging.slf4j.Slf4jImpl #指定POJO扫描包来让mybatis自动扫描到自定义的POJO mybatis.type-aliases-package=com.ocp.bizbase.entity #该配置就是将带有下划线的表字段映射为驼峰格式的实体类属性 #配置该项后,在开发中只需要根据查询返回的字段,创建好实体类就可以了 mybatis.configuration.map-underscore-to-camel-case=true
启动类配置 注解@MapperScan
import org.mybatis.spring.annotation.MapperScan; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.cloud.client.loadbalancer.LoadBalanced; import org.springframework.context.annotation.Bean; import org.springframework.web.client.RestTemplate; //import springfox.documentation.oas.annotations.EnableOpenApi; @SpringBootApplication(scanbasePackages = {"com.test.xxx.*"}) @EnableDiscoveryClient @MapperScan("mapper接口所在包路径") public class BizbaseApplication { public static void main(String[] args) { SpringApplication.run(BizbaseApplication.class, args); } @LoadBalanced @Bean public RestTemplate restTemplate() { return new RestTemplate(); } }
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)