我使用netbeans在腳本文件夾中創建了以下腳本。我無法保存域類。另外,如果我將整個項目部署爲war文件,我可以使用Windows調度程序運行腳本嗎?Groovy腳本保存域類
腳本
def json = ""
def txt = new URL("http://free.worldweatheronline.com/feed/weather.ashx?q=Singapore,Singapore&format=xml&num_of_days=1&key=b674fb7e94131612112609").text
def records = new XmlSlurper().parseText(txt)
def weather = records.weather
def dates = weather.date
def min = weather.tempMinC
def max = weather.tempMaxC
def img = weather.weatherIconUrl
def desc = weather.weatherDesc
def descLink = desc.toString().replaceAll(" ","%20")
println max
Weathers w = new Weathers()
w.cityName="singapore"
w.day = dates
w.description =desc
w.max = max
w.img = img
w.min = min
w.url = "jk"
域類
package org.mPest
class Weathers {
int id
String day
String min
String max
String img
String description
String cityName
String url
static constraints = {
id(blank:false, unique:true)
cityName(blank:false)
url(blank:false)
}
}