我使用 netbeans 在脚本文件夹中创建了以下脚本。我无法保存域类。另外,如果我将整个项目部署为 war 文件,我可以使用 Windows 调度程序运行脚本吗?
脚本
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)
}
}