Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SpringBoot-Zookeeper-Distributed-Lock #1

Closed
wanyuan123 opened this issue Apr 27, 2019 · 1 comment
Closed

SpringBoot-Zookeeper-Distributed-Lock #1

wanyuan123 opened this issue Apr 27, 2019 · 1 comment

Comments

@wanyuan123
Copy link

尊敬的作者,学习了你的关于Zookeeper分布式锁的实现,遇到了一个问题,想请教一下.问题是:我借鉴了你的SpringBoot-Zookeeper-Distributed-Lock这个工程,但是启动的时候有个报错:The bean 'distributedLockByZookeeper', defined in class path resource [com/yuqing/userCore/support/lock/SpringConfiguration.class], could not be registered. A bean with that name has already been defined in file [D:\code\v_1\yunSystem\yun-user\yun-user-core\target\classes\com\yuqing\userCore\support\lock\DistributedLockByZookeeper.class] and overriding is disabled.根据描述,是因为distributedLockByZookeeper这个类被重复注入了.看了源码,的确是会有两次注入,请问一下,你的解决办法是什么?是开启注入覆盖吗?

@liaozihong
Copy link
Owner

确实会有两次注入,这是我不小心在DistributedLockByZookeeper上标记了@service,导致SpringBoot对它自动注入了,去掉这个注解,在SpringConfiguration配置注入和初始化就可以了。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants