SpringBootMybatis 关于Mybatis-generator-gui的使用|数据库的编码注意点|各项复制模板

mysql注意点:

1.有关编码
create table user(
id int primary key auto_increment,
`name` varchar(255),
`password` varchar(255)
)ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8;
需要加上引擎的注释和默认数据库编码

application.properties的默认写法

#数据源
spring.datasource.url=jdbc:mysql://120.78.206.78:3306/testMybatisClient?useUnicode=true&characterEncoding=utf8
spring.datasource.username=root
spring.datasource.password=Root123..

#用来实例化mapper接口
mybatis.type-aliases-package=com.littlepage.mapper
#对应的sql映射
mybatis.mapper-locations=classpath:mybatis/mapper/*.xml
#首页
server.servlet.context-path=/
#日志级别
logging.level.com.littlepage.mybatis.mapper=debug

#连接池
spring.datasource.hikari.minimum-idle=3
spring.datasource.hikari.maximum-pool-size=10
spring.datasource.hikari.max-lifetime =30000
spring.datasource.hikari.connection-test-query=SELECT 1

MapperScan

@SpringBootApplication
@MapperScan("com.littlepage.mapper")
public class MybatisApplication {

    public static void main(String[] args) {
        SpringApplication.run(MybatisApplication.class, args);
    }

}
启动类进行mapper的扫描

 

posted @ 2019-07-06 12:18  SteveYu  阅读(469)  评论(0编辑  收藏  举报