From this question, it is possible to inject map with enums?
For example, i have enum:
class enum SomeEnum (val value) {
ONE("one"),
TWO("two"),
THREE("three")
}
And i have some interface with implementations:
interface SomeInterface {
}
@Component
@Qualifier("one")
class OneClass: SomeInterface {
...
}
@Component
@Qualifier("two")
class TwoClass: SomeInterface {
...
}
@Component
@Qualifier("three")
class ThreeClass: SomeInterface {
...
}
But such injection not works:
@Component
@ConfigurationProperties
class SomeProperties {
@Autowired
lateinit var someMap: Map<SomeEnum, SomeInterface>
}
I want to autoinject someMap
. How can i fix it, to make such code on spring framework side?
var someMap: Map<SomeEnum, SomeInterface> = Map.of(ONE, oneClass,
TWO, twoClass,
THREE, threeClass)
// Where oneClass, twoClass, threeClass - beans instances