Automatically assign spring's bean name to prevent name conflicts?

后端 未结 2 1733
情话喂你
情话喂你 2021-02-07 13:15

In a spring app , if two programmers develop two packages , annotating @Repository to the same class name , Spring will throw \"IllegalStateException\" :

2条回答
  •  旧时难觅i
    2021-02-07 13:40

    Somewhere in your config, you've enabled classpath scanning, probably using

    
    

    You can specify a property called name-generator, which takes a bean that implements the BeanNameGenerator interface. Create your own implementation of that interface and provide a reference to it.

提交回复
热议问题