栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 前沿技术 > 云计算 > 云平台

【踩坑记录】高级软件设计实作主题7druid配置问题的后续

云平台 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

【踩坑记录】高级软件设计实作主题7druid配置问题的后续

项目场景

主题7-搭建基础工程-搭建商品系统微服务(160分钟)第12周


问题描述

上篇踩坑记录中更改完运行时还是会报错https://blog.csdn.net/q_645566340/article/details/124698424
1.java.lang.NullPointerException: null
2.Caused by: com.mysql.cj.exceptions.InvalidConnectionAttributeException: The server time zone value ‘�й���׼ʱ��’ is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the ‘serverTimezone’ configuration property) to use a more specifc time zone value if you want to utilize time zone support.


原因分析

1是空指针
2是没添加时区参数


解决方案

更改依赖包和配置文件

原来(接上篇踩坑记录)的druid依赖包

        
            com.alibaba
            druid-spring-boot-starter
            1.1.10
        

改成

        
        
            com.alibaba
            druid
            1.1.9
        
        
        
            log4j
            log4j
            1.2.17
        

相比老师文档中给的代码而言,配置文件改的比较多
原来(老师给的)

server.port=10001
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql:///easydb?useUnicode=true&characterEncoding=utf8&autoReconnect=true&allowMultiQueries=true
spring.datasource.username=root
spring.datasource.password=12345678
spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
spring.datasource.initialSize=5
spring.datasource.maxActive=50
spring.datasource.maxIdle=10
spring.datasource.minIdle=5

mybatis.typeAliasesPackage=com.easymall.common.pojo
mybatis.mapperLocations=classpath:mapper/*.xml
mybatis.configuration.mapUnderscoreToCamelCase=true
mybatis.configuration.cacheEnabled=false
spring.application.name=productservice
eureka.client.serviceUrl.defaultZone=http://localhost:8761/eureka/

改成

server.port=10001
spring.datasource.druid.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.druid.url=jdbc:mysql:///easydb?useUnicode=true&characterEncoding=utf8&autoReconnect=true&allowMultiQueries=true&serverTimezone=UTC
spring.datasource.druid.username=root
spring.datasource.druid.password=123456
spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
spring.datasource.druid.initial-size=5
spring.datasource.druid.maxActive=50
#spring.datasource.druid.max-idle=10
spring.datasource.druid.min-idle=5

mybatis.typeAliasesPackage=com.drh.pojo
mybatis.mapperLocations=classpath:mapper/*.xml
mybatis.configuration.mapUnderscoreToCamelCase=true
mybatis.configuration.cacheEnabled=false
spring.application.name=productservice
eureka.client.serviceUrl.defaultZone=http://localhost:8761/eureka/

PS:包路径和数据库密码记得改成自己对应的

改完再运行就不报错了,并且能成功访问http://localhost:10001/product/manage/pageManage?page=1&rows=2

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/896723.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号