虽然一切正常,但我在域中添加了一些静态约束并删除了数据库并重新创建了它。之后我在引导程序中创建ADMIN和USER角色以及Demo USER和DEMO Admin但是我收到错误:
| Error 2016-03-31 13:33:21,834 [localhost-startStop-1] ERROR context.GrailsContextLoaderListener - Error initializing the application: null
Message: null
Line | Method
->> 111 | doCall in BootStrap$_closure1
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 327 | evaluateEnvironmentSpecificBlock in grails.util.Environment
| 320 | executeForEnvironment . . . . . in ''
| 296 | executeForCurrentEnvironment in ''
| 334 | innerRun . . . . . . . . . . . . in java.util.concurrent.FutureTask$Sync
| 166 | run in java.util.concurrent.FutureTask
| 1145 | runWorker . . . . . . . . . . . in java.util.concurrent.ThreadPoolExecutor
| 615 | run in java.util.concurrent.ThreadPoolExecutor$Worker
^ 722 | run . . . . . . . . . . . . . . in java.lang.Thread
Bootstrap代码:
def init = { servletContext ->
if (!Role.findByAuthority("ROLE_USER")) {
Role role = new Role(authority: 'ROLE_USER')
role.save(failOnError: true)
User user = new User(username: 'testUser', password: 'password1', enabled: true)
UserProfile profile1 = new UserProfile(fullName: "TEST", contactPhone: "8888888888", contactEmail: "test@test.com", displayName: "TEST", invoiceEmail: "test@gmail.com", invoiceDueDate: new Date(), defaultMap: MapType.GOOGLE)
user.profile = profile1
Device device1 = new Device(gpsDateTime: new Date(), vehicleId: "TEST", vehicleModel: "Hundai", imeiNumber: "000000000000000").save(flush: true, failOnError: true)
def test = new Account(notifyEmail: "test@test.com", allowNotify: true, name: 'TEST Car', device: device1).save(flush: true, failOnError: true)
user.addToDevices(device1)
user.save(failOnError: true, flush: true)
UserRole userRole = new UserRole(user: user, role: role)
userRole.save(failOnError: true, flush: true)
}
}
任何帮助将不胜感激。谢谢。