我想從我的實際腳本groovy文件中分離變量數據。使用單獨的數據文件來讀取groovy變量
def test = [a,b,c]
def test2 = ['foo': [a,x,y], 'bar': [q,w,e]]
def function(String var){}
def function2 {
test.each
{
item ->
print test
}
}
因爲我在變量中的值不斷變化,但不是腳本。如何讓我的groovy在運行時讀取一個變量文件並加載它?
我希望它看起來像這樣也許。
variables.properties
def test = [a,b,c]
def test2 = ['foo': [a,x,y], 'bar': [q,w,e]]
main.groovy
load (variable.properties)
def function(String var){}
def function2 {
test.each
{
item ->
print test
}
}
你會怎樣想的文件是什麼樣子? – daggett
@daggett我更新了我的問題來回答這個問題 – ShakyaS
您是否需要將變量定義明確地指定爲Groovy,還是隻使用任何常規數據格式(例如JSON屬性)? –