springboot相关文件配置(很容易出错)

======================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):....

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值