======================spring.datasource配置
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.data-username=root
spring.datasource.data-password=root
这三种配置会报错:Access denied for user ''@'localhost' (using password: NO) 因为中间有"-"我也不知道为啥()
解决方案(正确写法):
spring.datasource.driverClassName=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/cytesttest?uallowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8 //本地配置
dbc:mysql://localhost:3306/test?
spring.datasource.username=root spring.datasource.password=root
spring: application: name: product datasource: driverClassName: com.mysql.jdbc.Driver username: root password: 123456 url: jdbc:mysql://127.0.0.1:3306/springcloud?serverTimezone=UTC&characterEncoding=utf-8&allowPublicKeyRetrieval=true&useSSL=false jpa: show-sql: true
这个写法也是没有问题的!!!
奇怪的是idea默认推荐就是使用第一种写法!!
======mybatis配置文件
在idea 中的springboot项目中mapper.xml文件不和mapper.java写在一起,mapper.xml配置在resources目录下(这里比如在resources/mapper/Testmapper.xml),但是我在长城做的项目是写在一起的,那是怎么解决的呢???
则在application.properties中应该这样配置mybatis文件:
mybatis.mapper-locations=classpath:mapper/*.xml 同事在启动类配置@MapperScan("com.example.demo.mapper")
否则会报:Invalid bound statement (not found):....