Micronaut-core: @ConfigurationProperties with Lombok @Setter doesn't work

Created on 23 Dec 2019  路  3Comments  路  Source: micronaut-projects/micronaut-core

When i'm trying to use @ConfigurationProperties with Lombok @Setter annotation it doesn't inject values.

Steps to Reproduce

  1. Create simple micronaut project.
  2. Create class annotated with @ConfigurationProperties("foo.bar") and add String field "myparam". Add @Getter and @Setter annotation.
  3. Add property in application.yml:
    foo.bar.myparam: test-string-config
  4. Run app and log property "myparam". It will be null.
  5. Open MyNewParam.java. Use Intellij Idea menu "Refactor->Delombok->@Setter" and unwrap annotation. It should generate setters methods. Or do it manually.
  6. Run app and log property "myparam" again. It will be "test-string-config".

Expected Behaviour

Property "myparam" should has value "test-string-config"

Actual Behaviour

Property "myparam" is null

Environment Information

  • Operating System: OSX 10.14.6
  • Micronaut Version: 1.2.6
  • JDK Version: OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.5+10, mixed mode)

Example Application

https://github.com/denbilyk/micronaut-configurationproperties-lombok

notabug

All 3 comments

Can you try again defining the Lombok dependency before the Micronaut https://github.com/denbilyk/micronaut-configurationproperties-lombok/blob/develop/pom.xml#L174-L183?

Can you try again defining the Lombok dependency _before_ the Micronaut https://github.com/denbilyk/micronaut-configurationproperties-lombok/blob/develop/pom.xml#L174-L183?

Yes, that's works.
Will it be fixed or is it right behavior?
Thanks.

That's the correct behavior. Micronaut annotation processor must run after any other annotation processor: https://docs.micronaut.io/latest/guide/index.html#_using_project_lombok

Was this page helpful?
0 / 5 - 0 ratings