不可以,一个被'@Service' 标注的类只能有一个 Spring 的别名。如果需要为一个类指定多个别名,可以使用'@Component' 注解,并在每个别名上使用'@Qualifier' 注解来指定不同的名称。

关于'Duplicate annotation' 和'The declaration of 'org.springframework.beans.factory.annotation.Qualifier' does not have a valid java.lang.annotation.Repeatable' 的错误提示,可能是因为在使用'@Qualifier' 注解时使用了重复的别名或版本不兼容的问题。

Spring @Service 注解:一个类可以有多个别名吗?

原文地址: https://www.cveoy.top/t/topic/m8Jd 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录