I am learning Grails using version 1.3.7 and I keep running into the following syntax error for no apparent reason:
unexpected token: mapping @ line x, column y.
Once, I got rid of it by running “groovy clean” and “grails clean”, but this time it not even that is working. As far as I can tell, my code is exactly like the example in the book I’m using, and yet it keeps complaining about the word “mapping”.
Here is an example of one of my classes where it fails:
package com.grailsinaction
class Post {
String content
Date dateCreated
static constraints = {
content(blank: false)
}
static belongsTo = [ user: User ]
static mapping {
sort dateCreated: "desc"
}
static hasMany = [ tags: Tag ]
}
What am I missing? Please advise.
You’re missing an equals sign… The mapping line should read: