'Add a object with custom annotation in springboot

I need to add an object like @Slf4j's "log" in a service class, for example:

@Slf4j
@Service
public class MyService {
    public void anyMethod() {
        log.info("any log");
    }
}

in this case, @Slf4j is injecting the "log" object, is there any way I can do this with a custom annotation with another object ?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source