【问题标题】:Where does groovy look for properties files by default?默认情况下,groovy 在哪里查找属性文件?
【发布时间】:2016-07-23 15:20:11
【问题描述】:

对于这个 Netbeans 项目:

.
├── build.xml
├── manifest.mf
├── nbproject
│   ├── build-impl.xml
│   ├── genfiles.properties
│   ├── groovy-build.xml
│   ├── private
│   │   └── private.properties
│   ├── project.properties
│   └── project.xml
└── src
    ├── Config1.groovy
    └── net
        └── bounceme
            └── mordor
                └── groovy
                    └── file_ops
                        └── NewGroovyScript.groovy

8 directories, 10 files

foo.properties 的标准位置或路径是什么,以便 can be easily picked up?在src?

【问题讨论】:

  • 你试过把它放在 src 中和 NewGroovyScript.groovy 相同的文件夹吗?

标签: netbeans groovy configuration properties-file idioms


【解决方案1】:

你应该可以把它和你的 NewGroovyScript.groovy 类文件放在同一个文件夹中,然后这样做:

Properties p = NewGroovyScript.class.getResource('foo.properties').withInputStream { s ->
    Properties properties = new Properties()
    properties.load(s)
    properties
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-07-06
    • 2019-03-27
    • 1970-01-01
    相关资源
    最近更新 更多