zl程序教程

您现在的位置是:首页 >  其它

当前栏目

使用@Qualifier注解时候,报错:The annotation @Qualifier is disallowed for this location

报错 for The is 注解 this 时候 Location
2023-09-14 09:13:56 时间

问题描述:

在SpringBoot整合Druid数据库连接池时候,配置主从库数据源,使用@Qualifier注解进行注入Bean时候,编译错误,提示:

The annotation @Qualifier is disallowed for this location

错误原因:

  • import导入的包错误,导入了:import org.mapstruct.Qualifier;
import org.mapstruct.Qualifier;

 解决方案:

  • 导入spring下的包
import org.springframework.beans.factory.annotation.Qualifier;

注意:eclipse使用快捷键【ctrl+shift+o】导入包的时候,多个包时候,会弹框提示,此时选择自己需要导入的包。