如有不同意见,欢迎交流
报错
[com.alibaba.csp.sentinel.init.InitFunc]
Found repeat alias name for com.alibaba.csp.sentinel
Create breakpoint :
transportnit.Commandenterlnitfunc and com.alibaba.csp.sentinel.transportnit.CommandenternitFunc,
spI cnfiguration file-WETA-IMF/services/com.alibaba.csp.sentinel.init.InitFunc
at com.alibaba.csp.sentinel.spi.SpiLoader.fail(SpiLoader.java:525)
问题分析
大致意思是在加载Sentinel的SPI配置文件时发现了重复的别名(alias),即有两个类用同一个别名来注册到SPI中。
SPI是Java提供的一种机制,通过这种机制可以在运行时动态加载模块,每个模块都对应一个接口,实现该接口的类需要在SPI配置文件中注册,并指定一个别名。在该错误信息中,出现了两个类使用了相同的别名 com.alibaba.csp.sentinel.transportnit.CommandenternitFunc 和 com.alibaba.csp.sentinel.transportnit.Commandenterlnitfunc,因此出现了冲突。解决方法是修改其中一个类的别名,或者将其从SPI配置文件中删除。
解决方法
- 我遇见的这个问题的时候,是发现有两个controller类的头部写了相同的@RequestMapping(“/demo”),类中方法上又有相同的@RequestMapping(“/remove”),导致这两个不同的接口用了同一个地址。改掉其中的一个即可。