maven统一版本管理 错误记录

基本流程

问题一:父模块中指定了版本,但是子模块却没有读取到。

在子模块中指定 parent ,这里我父模块是 叫 test-demo

<parent>
		<groupId>com.yichen</groupId>
		<artifactId>test-demo</artifactId>
		<version>0.0.1-SNAPSHOT</version>
		<relativePath/> <!-- lookup parent from repository -->
</parent>

** 注意,这样指定 parent 后,spring-boot的版本号便会根据 父模块中指定的 spring-boot 版本号,这样可能会与 子模块中 的 spring-cloud 产生冲突

错误内容如下

The bean 'dataSource', defined in BeanDefinition defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class], could not be registered. A bean with that name has already been defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class] and overriding is disabled.

这个问题百度了一下,好多只说了解决方法,通过该错误附带的提示即可解决
在 配置文件中添加 spring.main.allow-bean-definition-overriding=true 即可。但是产生错误的原因基本都没找,后面排查了一下问题,发现是 spring-boot 版本 和 spring-cloud 版本不一致,因为我一开始 spring-boot 的版本不是现在父模块中指定的版本号。

这里给出后面我修改后的对应版本号。

//  父模块中
<parent>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-starter-parent</artifactId>
   <version>2.3.4.RELEASE</version>
   <relativePath/> <!-- lookup parent from repository -->
</parent>
   // 子模块中
<dependency>
   <groupId>com.alibaba.cloud</groupId>
   <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
   <version>2.2.4.RELEASE</version>
</dependency>
<dependency>
   <groupId>com.alibaba.cloud</groupId>
   <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
   <version>2.2.4.RELEASE</version>
</dependency>

运行程序报错

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
都说了需要在url中添加 serverTimeZone,但是 serverTimezone=Asia/Hongkong 行不通,serverTimezone=UTC%2b8 也行不通,查了一下 /usr/share/zoneinfo(我用的是window的WSL),内容如下
在这里插入图片描述
里面有个Hongkong,试了一下 serverTimezone=Hongkong 成功。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值