gpt4 book ai didi

Gradle - 从 .properties 文件加载属性

转载 作者:行者123 更新时间:2023-12-02 06:12:04 27 4
gpt4 key购买 nike

尝试在 build.gradle 文件中添加 db.properties 文件时遇到此错误

构建.gradle:

allprojects {

apply from: 'db.properties'
apply from: 'deployment.properties'

repositories {
mavenCentral()
}

apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'maven-publish'
apply plugin: 'idea'

sourceCompatibility = 1.8

}

数据库属性:

db=blal
dbUsername=/bilal/home

我得到的错误是:

* Where:
Script 'camelawsextractionservicesb/db.properties' line: 1

* What went wrong:
A problem occurred evaluating script.
> Could not find property 'blal' on root project 'CamelExtractionServices'.

最佳答案

如果您希望从 .properties 文件加载属性,我会尝试这样的操作:

ext.additionalProperties = new Properties().load(file("db.properties").newReader())
ext.someOtherProperties = new Properties().load(file("foo.properties").newReader())

然后您可以访问您的属性:

println additionalProperties['db']
println someOtherProperties['bar']

关于Gradle - 从 .properties 文件加载属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35901072/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com