Consider marking one of the beans as @Primary, updating the consumer to accept multiple beans, or us

一、问题

Description:

Field userService in com.yh.controller.UserController required a single bean, but 2 were found:
    - serviceUserServiceImpl: defined in file [C:\Users\wxt\Desktop\dubbo\consumer-service1\target\classes\com\yh\service\ServiceUserServiceImpl.class]
    - userServiceImpl: defined in file [C:\Users\wxt\Desktop\dubbo\provider-service\target\classes\com\yh\service\impl\UserServiceImpl.class]


Action:

Consider marking one of the beans as @Primary, updating the consumer to accept multiple beans, or using @Qualifier to identify the bean that should be consumed

2023-10-02 21:36:32.969  INFO 54384 --- [bboShutdownHook] o.apache.dubbo.config.DubboShutdownHook  :  [DUBBO] Run shutdown hook now., dubbo version: 2.7.3, current host: 192.168.43.212
2023-10-02 21:36:32.970  INFO 54384 --- [bboShutdownHook] o.a.d.r.support.AbstractRegistryFactory  :  [DUBBO] Close all registries [], dubbo version: 2.7.3, current host: 192.168.43.212

Process finished with exit code 1
 

二、分析

因为sringboot通过@Autowired注入接口的实现类时发现有多个,也就是有多个类继承了这个接口,spring容器不知道使用哪一个。

三、解决

1 我自己出现该问题的场景描述:

我在实现dubbo远程调用时出出现的错误;

接口1继承了接口2,然后又在接口1的实现类中使用@Reference将接口2注入。

2 我的解决办法:

接口1不去继承接口2;

在接口1中直接定义方法,在接口1的实现类中使用@Reference将接口2注入。即:

public interface ServiceUserService{
    List<User> findList();
    String msg();
}
@Service
public class ServiceUserServiceImpl implements ServiceUserService {
    @Reference
    private UserService userService;

    public List<User> findList() {
        return userService.findList();
    }

    public String msg() {
        return "消费者1业务层处理业务:consumer-service1"+userService.msg();
    }
}

另外,我还看到了其他博主的解决方法

第一种、加@Primary表示某个实现类首选注入

@Configuration("")

public class ActivitiConfig {

   @Autowired

   ProcessEngineConfiguration processEngineConfiguration;

   //流程配置,与spring整合采用SpringProcessEngineConfiguration这个实现

   @Bean

   @Primary

   public ProcessEngineConfiguration processEngineConfiguration(DataSource dataSource,

                                                                PlatformTransactionManager transactionManager){

       return processEngineConfiguration;

   }

}

第二种、@Autowired和@Qualifier(value = "beanName")结合使用

@Configuration

public class ActivitiConfig {

   @Autowired

   @Qualifier(value = "processEngineConfigurationImpl")

   ProcessEngineConfiguration processEngineConfiguration;

}

@Service("processEngineConfigurationImpl")

public class ProcessEngineConfigurationImpl extends  ProcessEngineConfiguration{

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
注:下载后,评价给5星,还你11分 Part I. Basic and Advanced vi 1. The vi Text Editor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 A Brief Historical Perspective 5 Opening and Closing Files 6 Quitting Without Saving Edits 10 2. Simple Editing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 vi Commands 13 Moving the Cursor 14 Simple Edits 18 More Ways to Insert Text 30 Joining Two Lines with J 31 Review of Basic vi Commands 32 3. Moving Around in a Hurry . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 Movement by Screens 35 Movement by Text Blocks 38 Movement by Searches 39 Movement by Line Number 43 Review of vi Motion Commands 44 4. Beyond the Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47 More Command Combinations 47 Options When Starting vi 48 Making Use of Buffers 51 Marking Your Place 52 Other Advanced Edits 53 Review of vi Buffer and Marking Commands 53 vii 5. Introducing the ex Editor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55 ex Commands 55 Editing with ex 58 Saving and Exiting Files 63 Copying a File into Another File 65 Editing Multiple Files 65 6. Global Replacement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71 Confirming Substitutions 72 Context-Sensitive Replacement 73 Pattern-Matching Rules 74 Pattern-Matching Examples 81 A Final Look at Pattern Matching 89 7. Advanced Editing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95 Customizing vi 95 Executing Unix Commands 99 Saving Commands 103 Using ex Scripts 114 Editing Program Source Code 120 8. Introduction to the vi Clones . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125 And These Are My Brothers, Darrell, Darrell, and Darrell 125 Multiwindow Editing 126 GUI Interfaces 127 Extended Regular Expressions 128 Enhanced Tags 129 Improved Facilities 134 Programming Assistance 138 Editor Comparison Summary 140 Nothing Like the Original 141 A Look Ahead 141 Part II. Vim 9. Vim (vi Improved): An Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145 Overview 146 Where to Get Vim 150 Getting Vim for Unix and GNU/Linux 151 Getting Vim for Windows Environments 156 Getting Vim for the Macintosh Environment 157 Other Operating Systems 157 viii | Table of Contents Aids and Easy Modes for New Users 157 Summary 158 10. Major Vim Improvements over vi . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159 Built-in Help 159 Startup and Initialization Options 160 New Motion Commands 167 Extended Regular Expressions 169 Customizing the Executable 171 11. Multiple Windows in Vim . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173 Initiating Multiwindow Editing 174 Opening Windows 177 Moving Around Windows (Getting Your Cursor from Here to There) 180 Moving Windows Around 181 Resizing Windows 183 Buffers and Their Interaction with Windows 186 Playing Tag with Windows 190 Tabbed Editing 191 Closing and Quitting Windows 192 Summary 193 12. Vim Scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195 What’s Your Favorite Color (Scheme)? 195 Dynamic File Type Configuration Through Scripting 205 Some Additional Thoughts About Vim Scripting 213 Resources 218 13. Graphical Vim (gvim) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219 General Introduction to gvim 220 Customizing Scrollbars, Menus, and Toolbars 225 gvim in Microsoft Windows 236 gvim in the X Window System 237 GUI Options and Command Synopsis 237 14. Vim Enhancements for Programmers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239 Folding and Outlining (Outline Mode) 240 Auto and Smart Indenting 251 Keyword and Dictionary Word Completion 259 Tag Stacking 268 Syntax Highlighting 270 Compiling and Checking Errors with Vim 279 Some Final Thoughts on Vim for Writing Programs 284 Table of Contents | ix 15. Other Cool Stuff in Vim . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285 Editing Binary Files 285 Digraphs: Non-ASCII Characters 287 Editing Files in Other Places 289 Navigating and Changing Directories 290 Backups with Vim 292 HTML Your Text 293 What’s the Difference? 294 Undoing Undos 296 Now, Where Was I? 297 What’s My Line (Size)? 300 Abbreviations of Vim Commands and Options 302 A Few Quickies (Not Necessarily Vim-Specific) 303 More Resources 304 Part III. Other vi Clones 16. nvi: New vi . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 307 Author and History 307 Important Command-Line Arguments 308 Online Help and Other Documentation 309 Initialization 309 Multiwindow Editing 310 GUI Interfaces 311 Extended Regular Expressions 311 Improvements for Editing 312 Programming Assistance 315 Interesting Features 315 Sources and Supported Operating Systems 315 17. Elvis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 317 Author and History 317 Important Command-Line Arguments 317 Online Help and Other Documentation 319 Initialization 319 Multiwindow Editing 320 GUI Interfaces 323 Extended Regular Expressions 328 Improved Editing Facilities 328 Programming Assistance 332 Interesting Features 335 elvis Futures 340 x | Table of Contents Sources and Supported Operating Systems 340 18. vile: vi Like Emacs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 343 Authors and History 343 Important Command-Line Arguments 344 Online Help and Other Documentation 345 Initialization 346 Multiwindow Editing 347 GUI Interfaces 349 Extended Regular Expressions 357 Improved Editing Facilities 359 Programming Assistance 365 Interesting Features 368 Sources and Supported Operating Systems 374
Volume 1 of Structure and Bonding was published in 1966 and the Preface suggested that “a valuable service is performed by bringing together up-to-date authoritative reviews from the different fields of modern inorganic chemistry, chemical physics and biochemistry, where the general subject of chemical bonding involves (usually) a metal and a small number of associated atoms. These arrangements are of importance for symmetry considerations by crystallographers, for the application of group theory and molecular orbital theory to chromophores and because of their widespread occurrence in polyatomic molecules, in complex ions in solution, in vitreous materials, in minerals and, not least, in biological materials and organisms. We are especially interested in the role of “the complex metalligand” moiety and purposely avoiding the more classical organic chemistry and even organo-metallic chemistry – for which many review journals are already available – and wish to direct attention towards borderline subjects. We are convinced that these borderline areas receive less attention than they justify, academic studies tend too often to be compartmentalized whereas technological interest too often lack sufficient fundamental understanding. We hope that his series may help to bridge the gaps between some of these different fields and perhaps provide in the process some stimulation and scientific profit to the reader”. Fifty years on and 175 volumes later, Structure and Bonding still plays a very important role in presenting authoritative reviews on structural and bonding issues in chemistry. To celebrate this significant landmark, we have invited recent editors and authors, who have contributed highly cited and noteworthy volumes and chapters in recent volumes of the series, to write chapters which highlight important new developments in their chosen area and indicate significant future developments. This volume marking the 50th anniversary starts with a historical introduction by myself, which traces the early days of the series and its social and intellectual context, and a summary of the contributions of the members of the editorial board. This is followed by noteworthy chapters by Philip Gale on anion receptors based on organic frameworks, Richard Winpenny on single molecule magnets, Thomas Klotke on recent progress in the development of high energydensity materials, David Evans and Xue Duan on layered double hydroxide materials. Peter Roesky has contributed a chapter on sigma bonded metathesis and polymerisation of 1,3-dienes by rare earth complexes, Yasuhiro Takabayashi and Kosmas Prassides on fullerene superconductivity and Dan Rabonovich on the role of scorpionates in synthetic bioinorganic chemistry. The important optical properties of transition metal complexes and their theoretical interpretation are covered in chapters by Jianzhuang Jiang and Yongzhong Bian on phthalocyanine based functional materials, and Vivian Yam has contributed a very detailed chapter on photofunctional molecular materials. Andreas Hauser and Christian Reber discuss the spectroscopic properties and chemical bonding in transition metal complexes. Professor Dirk Reinen was a member of the original editorial board of Structure and Bonding and we are very lucky that he has contributed with P Kohler a chapter on ligand field theory and discusses the fascinating colours of solid iron(III) oxides, an area which he first analysed in an early volume of Structure and Bonding. I thank all of these authors very much for their timely contributions and hope that their efforts will stimulate the successful launching of future volumes which will mark the next 50 years in the series' distinguished history.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小天博客

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值