Originally posted by **rsalbergaria** October 9, 2024
We are using version **4.5.1** of the parent and everything works perfectly. I tried updating to **4.6.0**, **4.6.1**, **4.6.2**, and **4.6.3** and for some reason, my dependency injections are compromised. I have something like:
```java
@Bean
@Singleton
@Requires(property = "SERVER")
public OAuth2ClientConfig provideOAuth2ClientConfig(Config config) {
return OAuth2ClientConfig.builder()
.server((URI) config.getValue("SERVER", URI.class))
.authUser((String) config.getValue("USER", String.class))
.authPass((String) config.getValue("PASSWORD", String.class))
.scopes((List) config.getOptionalValues("SCOPES", String.class).orElse(ListUtil.EMPTY))
.build();
}
Even with the property SERVER set, the config is not being injected. We have our own annotations and map them to the corresponding annotations in each Java framework we use:
public class RequiresAnnotationMapper implements TypedAnnotationMapper {
@Override
public Class annotationType() {
return Requires.class;
}
@Override
public List> map(AnnotationValue annotation, VisitorContext visitorContext) {
List> mappedAnnotations = new LinkedList<>();
var mappedAnnotation = resolveAnnotation(annotation);
mappedAnnotations.add(mappedAnnotation);
return mappedAnnotations;
}
private AnnotationValue resolveAnnotation(AnnotationValue annotation) {
return AnnotationValue.builder(io.micronaut.context.annotation.Requires.class)
.member("beans", annotation.annotationClassValues("beans"))
.member("property", resolveProperty(annotation))
.member("value", annotation.get("value", String.class).orElse(""))
.member("defaultValue", annotation.get("defaultValue", String.class).orElse(""))
.build();
}
private String resolveProperty(AnnotationValue annotation) {
return annotation.get("property", String.class)
.map(e -> e.toLowerCase().replace("_", "."))
.orElse("");
}
}
We also have the file io.micronaut.inject.annotation.AnnotationMapper with the path to our annotations. Did something change in 4.6.x that could be causing this issue?
Discussed in https://github.com/micronaut-projects/micronaut-platform/discussions/1704