0
BootStrap.groovy加載開發數據存在問題。之前它總是加載數據,但現在已經停止運行grails run-app時拋出下面的錯誤。Grails - BootStrap.groovy - 空指針問題
Message: Validation Error(s) occurred during save():
- Field error in object 'spotlight.content.Profile' on field 'portfolio': rejected value [null];
我的2個型號如下;
class Portfolio {
Profile profile
String portfolioName
String portdescrip
Integer portpublished
Date dateCreated
Date lastUpdated
和
class Profile {
static belongsTo = [portfolio: Portfolio]
String portfoliohtml
String portfolioEmail
String portfoliocc
String portfolioAdmin
String portfolioFilestore
String portfolioColor
String bugzillaproduct
String bugzillacomponent
String rtqueue
String teamqueueemail
String etherpadurl
Integer siteupload
Date dateCreated
Date lastUpdated
內BootStrap.groovy中的文件,我有以下幾點;
import java.util.Date;
import spotlight.content.Profile
import spotlight.content.Portfolio
class BootStrap {
def init = { servletContext ->
def profile = new Profile(portfoliohtml:"No",
portfolioEmail: "[email protected]",
portfolioAdmin:"Ian Neilsen",
bugzillaproduct:"bz prod name",
bugzillacomponent:"comp name",
siteupload:1,
portfoliocc: "[email protected]",
portfolioColor:"red",
portfolioFilestore:"blah",
rtqueue:"queue name",
teamqueueemail:"[email protected]",
etherpadurl:"http://url.com",
).save(failOnError: true)
def portfolio = new Portfolio(portfolioName:"Portfolio 1",
portdescrip:"portfolio descrition field",
portpublished:1,
portfolio:profile).save(failOnError: true)
}
我已經嘗試過將我的配置文件對象添加到投資組合對象沒有任何運氣的每一個化身。正如我之前所說,這工作,並已停止投擲空錯誤。
讓我難住了任何想法?
歡呼
哦,非常感謝男士。下午晚些時候,你剛剛把我的頭撞在桌子上。仍然有我難住爲什麼這之前工作。我已經通過應用程序從siteprofile更改了模型配置文件,並從此決定放棄地球表面。仍在學習Grails。謝了哥們 – IanN