私はGrailsアプリケーションのメンバシップと認証を管理するためにSpring Security Pluginを使用しています。Grails Spring Security Plugin - ユーザドメインとの1対1の対応
私は、ユーザードメインクラスとプロファイルドメインを1対1の関連付けで関連付けようとしています。
私はUser.groovyにこれらの行を追加しました:
static hasOne = [userProfile:UserProfile]
static constraints = {
//...
userProfile unique:true
}
とUserProfile.groovyへ:UseRole.create(ユーザー、役割)を呼び出すとき
User user
ああ、私はエラーが発生しました。
私が探しているのと同じ機能を得るには、いくつかのベストプラクティスがあります。特に、あるユーザーを1つのプロファイルオブジェクトに関連付けて、そのプロファイルオブジェクトを拡張したいと考えています。
私は、その後も...
おかげ 宜しく
PS投稿や他のテーブルと1対多の関係を追加したい:私はこのエラーを取得 を:
の設定春のセキュリティUI ... 2011-03-08 12:18:51,179 [main] ERROR context.GrailsContextLoader - ブートストラップの実行中のエラー:null java.lang.NullPointerException at $ Proxy19.save(不明なソース) a BootStrap $ _closure1.doCall(BootStrap.groovy:0)の でcom.dromedian.xxxxx.security.UserRole.create(UserRole.groovy:32) をcom.dromedian.xxxxx.security.UserRole $ create.call(不明なソース) 20) at grails.util.Environment.evaluateEnvironmentSpecificBlock(Environment.java:251) at grails.util.Environment.executeForEnvironment(Environment.java:244) at grails.util.Environment.executeForCurrentEnvironment(Environment.java:220) _GrailsRun_groovyで :_GrailsRun_groovy $ _run_closure5_closure12.doCall(158 _GrailsRun_groovy)でgrails.web.container.EmbeddableServer $ start.call(不明なソース)で :org.grails.tomcat.TomcatServer.start(212 TomcatServer.groovy)で $ _run_closure5_closure12.doCall(_GrailsRun_groovy)_GrailsRun_groovy $ _run_closure5.callで _GrailsRun_groovy.runInlineで(_GrailsRun_groovy) (:_GrailsSettings_groovy $ _run_closure10.call(_GrailsSettings_groovy)_GrailsRun_groovy $ _run_closure5.doCall(149 _GrailsRun_groovy)で で :_GrailsSettings_groovy $ _run_closure10.doCall(280 _GrailsSettings_groovy)で_GrailsRun_groovy:116)で _GrailsRun_groovy.this $ _GrailsRun_groovy $ _run_closure1.doCall(_GrailsRun_groovyで4 $ runInline(_GrailsRun_groovy) :gant.Gant $ _dispatch_closure5.doCallで33) :RunApp $ _run_closure1.doCall(RunApp.groovyにおける59) (Gant.groovy:415) at gant.Gant $ _dispatch_closure7.doCall(Gant.groovy:415) でgant.Gant $ _dispatch_closure7.doCall Gant.Gant.withBuildListeners(Gant.groovy:427) gant.Gant.this $ 2 $ withBuildListeners(Gant.groovy) gant.Gant $ thisByildListeners.callCurrent(不明なソースgant.Gant.executeTargetsでgant.Gant.this $ 2 $派遣(Gant.groovy)gant.Gant.invokeMethod(Gant.groovyで で415) ) (:gant.Gant.dispatchで) (Gant.groovyガント。グルーヴィー:gant.Gant.executeTargets(Gant.groovyで590) :設定...
をシャットダウン589) アプリケーションコンテキストは次のとおりです。
User.groovy(スプリングセキュリティプラグインによって作成されたドメインクラス)
static hasOne = [userDetail:UserDetail]
static constraints = {
username blank: false, unique: true
password blank: false
userDetail unique:true
}
UserDetail.groovy
static hasOne = [user:User]
static belongsTo = User
BootStrap.groovy
//TODO temporary added - no for production or persistent db
def adminRole = new Role(authority: 'ROLE_ADMIN').save(flush: true)
def userRole = new Role(authority: 'ROLE_USER').save(flush: true)
String password = springSecurityService.encodePassword('password')
def testUser = new User(username: 'me', enabled: true, password: password)
testUser.save(flush: true)
if(testUser != null){
UserRole.create testUser, adminRole, true
}
私は
UserRole.create testUser, adminRole, true
を呼び出さない場合はエラーがありません。私はデバッグしようとしましたが、エラーがどこにあるのか分かります。
あなたの画面を見るための魔法の力がないので、エラーメッセージを表示する必要があります。 ;) – Gregg
あなたはどのようなエラーメッセージが表示されているのかを具体的に理解する必要があります。 – jjczopek
申し訳ありませんが、私は今、エラーメッセージを投稿しました:) – ryuujin