https://kotlinlang.org logo
#spring
Title
d

davidkarlsen

09/19/2019, 5:31 PM
the qualifier does not seem to be taken into consideration…
l

leodeng

09/19/2019, 5:39 PM
can you try using @Qualifier, or maybe renaming the variable to jaxWsClientBus
d

davidkarlsen

09/19/2019, 5:42 PM
tried both - same outcome
I suspect something about inheritance?
l

leodeng

09/19/2019, 5:45 PM
how about @field:Qualifier
d

davidkarlsen

09/19/2019, 5:48 PM
If I do
Copy code
class SecurityConfig(@Autowired @Qualifier("jaxWsClientBus") bus: Bus) : AbstractJaxWsClientStubConfig(bus) {
it works
but that’s a bit annoying
l

leodeng

09/19/2019, 5:50 PM
did you try
@field:Qualifier("jaxWsClientBus")
?
d

davidkarlsen

09/19/2019, 5:52 PM
then i get `expected annotation identified after ':'``
ait
it should be in an array
YES!
we have a winner
Copy code
@field:[Qualifier("jaxWsClientBus") Inject]
    protected lateinit var bus: Bus
thanks a lot!
l

leodeng

09/19/2019, 6:01 PM
np. but wouldnt
Copy code
@field:Qualifier("jaxWsClientBus")
    protected lateinit var bus: Bus
work?
d

davidkarlsen

09/19/2019, 6:02 PM
Caused by: kotlin.UninitializedPropertyAccessException: lateinit property bus has not been initialized
nope
l

leodeng

09/19/2019, 6:05 PM
ah, sorry. you also need @Autowired or @Inject
if that does not work, you will also need field: prefix
and then it leads to your array-style use, which is new to me. i always use annotaions separately
just out of curiosity, i did a few experiments, and found out that only @Named must have the
field:
prefix. so the bare minimum that works can be:
Copy code
@Inject
@field:Named("jaxWsClientBus")
or
Copy code
@Autowired
@Qualifier("jaxWsClientBus")
@Inject and @Autowired are interchangeable
12 Views