Java .properties files as strongly typed classes

后端 未结 8 1195
小蘑菇
小蘑菇 2021-01-02 14:50

Is there way to get properties files as strongly typed classes? I guess there are code generators but doing it with annotations would be much cooler.

What I mean is;

8条回答
  •  半阙折子戏
    2021-01-02 15:18

    The Annotation Processing Tool (apt) cannot modify classes (though it can create new ones). In order to modify the class at compile time, you'd probably need to edit the AST (as Project Lombok does). The simplest approach would probably be to generate the classes and then use the generated library as a dependency for other code.

提交回复
热议问题