简体   繁体   English

带有ConfigObject和ConfigSlurper的常规类型安全配置

[英]groovy typesafe configurations with ConfigObject and ConfigSlurper

I am using a groovy configuration file and parse it with ConfigSlurper resulting in a ConfigObject that I use for accessing my configuration. 我正在使用一个常规的配置文件,并使用ConfigSlurper对其进行解析,从而生成一个ConfigObject,用于访问我的配置。 The disadvantage is that I have no help from eclipse regarding if properties exist - every configuration property is underlined as groovy/eclipse do not know which properties the (dynamic) ConfigObject has. 缺点是eclipse对属性是否存在没有帮助-每个配置属性都带有下划线,因为groovy / eclipse不知道(动态)ConfigObject具有哪些属性。 Refactoring is also not possible - for example if I rename a property in the config, groovy/eclipse does not recognise its usages in the sourcecode and does not rename it there. 重构也是不可能的-例如,如果我在配置中重命名属性,groovy / eclipse将无法在源代码中识别其用法,也不会在源代码中对其重命名。

Are there ways to fix or workaround these two issues? 有没有办法解决或解决这两个问题?

Groovy-eclipse DSL Descriptors come to mind: 想到Groovy-eclipse DSL描述符

DSL示例

Also, @TypeChecked extensions may be used if you want type safety in your DSL. 另外,如果您要在DSL中输入类型安全性,则可以使用@TypeChecked扩展名

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM