Sonarqube configuration
- Developer Edition
- Version 8.9.8 (build 54436)
Problem description
Eclipse MicroProfile Config specification allows only field injection. Constructor injection is not available.
Exemple :
@Inject
@ConfigProperty(name="myprj.some.url")
private String someUrl;
So I think that the rule java:S3306 " Constructor injection should be used instead of field injection" is not relevant in that case.
Otherwise, as I’m using this in an ejb Singleton annotated @Startup, I can’t turn the default constructor ‘private’ because it raise an exception :
[INFO] [ERROR ] CWWKZ0004E: Une exception s'est produite lors du démarrage de l'application XXX. Le message d'exception était : com.ibm.ws.container.service.state.StateChangeException: com.ibm.ws.cdi.CDIException: com.ibm.wsspi.injectionengine.InjectionException: com.ibm.ejs.container.EJBConfigurationException: EJB class com.mycompany.MyEJB must have a public constructor that takes no parameters