How can I mark a Bean as deprecated in Spring / Kotlin

Viewed 291

In my codebase I currently have a restTemplate bean and a WebClient bean. I would like to mark the restTemplate as deprecated as we want to progressively move away from it.

I have my 2 beans in my Configuration file:

    @Deprecated(message = "Please use WebClient instead")
    @Bean
    fun restTemplate(): RestTemplate =
        RestTemplateBuilder()
                .requestFactory { HttpComponentsClientHttpRequestFactory() }
                .build()

    @Bean
    fun baseWebClient(): WebClient =
        WebClient.builder().build()

However, when I autowire a RestTemplate, I don't see any deprecated warnings

How can I achieve that?

0 Answers
Related