我使用groovy语言(// this fails, and the application is not able to load, saying that it's not able to inject ArghRepo:
// File: ArghRepo.java
@Repository
public class ArghRepo implements IArgh {
@Cacheable(value = "test", cacheManager = "springCM")
public String testString(String test) {
System.out.println("Cache is not hit: " + test);
return test;
}
// File: IArgh.java
public interface IArgh {
String testString(String test);
}
)编写了这个脚本:
datediff.groovy
工作正常。不过,我打算将这些脚本移到(doc[secondDateField].date.millis - doc[firstDateField].date.millis) / 3600000
(painless
)。然而,我在straup上遇到了编译错误:
datediff.painless
它告诉我[esn1] failed to load/compile script [datediff]: {
"type" : "script_exception",
"reason" : "compile error",
"caused_by" : {
"type" : "illegal_argument_exception",
"reason" : "Variable [secondDateField] is not defined."
},
"script_stack" : [
"(doc[secondDateField].date.mil ...",
" ^---- HERE"
],
"script" : "(doc[secondDateField].date.millis - doc[firstDateField].date.millis) / 3600000",
"lang" : "painless"
}
没有定义。你能帮助我吗?
secondDateField
不是名为secondDateField
的字段。它是一个脚本参数(如secondDateField
),doc [parameter]应该访问firstDateField
内容中设置的字段。如果parameter
,secondDateField = "fieldOne"
...
答案 0 :(得分:0)
如果您尝试将其转换为毫秒,那么您的查询应该在DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=33060
DB_DATABASE=idy
DB_USERNAME=homestead
DB_PASSWORD=secret
中看起来像这样,并且您之前和之后都错过了单引号SELECT tblStudInfo.LastName AS myName, tblAddress.Address AS myAddress, tblCourses.CourseName AS myCourse
FROM ((tblStudInfo
INNER JOIN tblAddress ON tblStudInfo.AddressID = tblAddress.AddressID )
INNER JOIN tblCourses ON tblStudInfo.CourseCode = tblCourses.CourseCode)
WHERE tblStudInfo.StudID = '01-2016-003'
我担心的字段名称:
Painless
根据{{3}},毫秒应该是毫秒。
希望这有帮助!