Я установил приложение весны безопасности от й Граалей плагина страницы после запуска grails s2-quickstart com.testApplication.secureApplication User Role
автоматического создания объекта домена я сделал grails run-app
и получил это исключение:Grails 2 - Невозможно создать пружинный объект домена безопасности
|Loading Grails 2.3.4
|Configuring classpath
.
|Environment set to development
.................................
|Packaging Grails application
Precompiling AST Transformations ...
src C:\Users\GrailsWorkspace\testApplication\target\work\plugins\postgresql-extensions-0.6.1 C:\Users\GrailsWorkspace\testApplication\target\classes
Done precompiling AST Transformations!
..
|Compiling 3 source files
...................................................
|Running Grails application
Configuring Spring Security Core ...
... finished configuring Spring Security Core
Error |
2013-12-15 15:42:45,635 [localhost-startStop-1] ERROR hbm2ddl.SchemaExport - Unsuccessful: create table user (id int8 not null, version int8 not null, account_expired bool not null, account_locked bool not null, enabled bool not null, "password" varchar(255) not null, password_expired bool not null, username varchar(255) not null unique, primary key (id))
Error |
2013-12-15 15:42:45,638 [localhost-startStop-1] ERROR hbm2ddl.SchemaExport - ERROR: syntax error at "user"
Position: 14
Error |
2013-12-15 15:42:45,688 [localhost-startStop-1] ERROR hbm2ddl.SchemaExport - Unsuccessful: alter table user_role add constraint FK143BF46A1E03E05D foreign key (user_id) references user
Error |
2013-12-15 15:42:45,688 [localhost-startStop-1] ERROR hbm2ddl.SchemaExport - ERROR: syntax error at "user"
Position: 90
|Server running.
Дела в том, моя база данных настроена правильно, потому что я получаю таблицу role
и user_role
. Однако пользователь не получает генерации в моем postgresql db
. Моя реализация моего сгенерированного user domain object
выглядит следующим образом:
class User {
transient springSecurityService
String username
String password
boolean enabled = true
boolean accountExpired
boolean accountLocked
boolean passwordExpired
static transients = ['springSecurityService']
static constraints = {
username blank: false, unique: true
password blank: false
}
static mapping = {
password column: '`password`'
}
Set<Role> getAuthorities() {
UserRole.findAllByUser(this).collect { it.role } as Set
}
def beforeInsert() {
encodePassword()
}
def beforeUpdate() {
if (isDirty('password')) {
encodePassword()
}
}
protected void encodePassword() {
password = springSecurityService.encodePassword(password)
}
}
Я ценю ваш ответ!
нет бы никогда мыслей о 'user' быть ключевым словом, спасибо! –