I am trying to implement my own annotation, the main logic will be inpostProcessAfterInitialization, in order to define annotated beans, implementedpostProcessBeforeInitializationSo:

private val map= mutableMapOf <
String, Class <
Any >
override fun postProcessBeforeInitialization (bean: Any, beanName: String): Any? {
    val beanClass= bean.javaClass
    if (beanClass.isAnnotationPresent (MyAnnotation :: class.java)) {
        map [beanName]= beanClass
    return bean

The problem is that, by design, my annotation should be placed above the main class, which in turn is annotated@SpringBootAnnotationand apparently because of this in the methodpostProcessBeforeInitializationa proxy comes to me as a bean, and not the original class.

Accordingly, the proxy is annotated with annotation only@SpringBootAnnotation, my annotation above the proxy class is not there, my question is is it possible to somehow get the original of the class that is annotated with@SpringBootAnnotation?

I know that you can get the original class from the proxy usingbean.javaClass.superclassbut not sure if this is a very good solution

OK. In the evening I will put together a test project that suits your conditions and see what may be wrong there. When I was implementing BeanPostProcessors, this was the only problem I had.

Михаил Ребров2021-12-11 14:39:08

there, under the answer, read the comments later, if interested

Михаил Ребров2021-12-11 14:39:08