Mongodb Morphia Plugin (v.0.7.8) を使用して Grails アプリで Mongodb を使用しようとしています。com.google.code.morphia.annotations.Entity アノテーションを使用して、ドメインクラス ( grails-app/mongo フォルダー内にない) にアノテーションを付けました。
import com.google.code.morphia.annotations.Entity
@Entity("Question")
class Question {
Integer order
String question
}
今、新しいエンティティをコントローラーのデータベースに保存しようとしています:
def index() {
def q = new Question()
}
q.save()
しかし、それは HTTP 500 エラーを引き起こします:
java.lang.IllegalStateException
Method on class [Question] was used outside of a Grails application. If running in the context of a test using the mocking API or bootstrap Grails correctly.
私は何を間違っていますか?
編集:
ドメイン クラスを grails-app/mongo に移動し、@Entity アノテーションを削除しました。エラーは消えましたが、データベースはまだ空ですか?
編集2:
今私は得る:
URI
/Survey/survey/index
Class
java.lang.NoSuchMethodException
Message
survey.Survey.<init>()
このプラグインは深刻なバグがあるか、クイックスタートのマイクロ例が示唆するほどセットアップが簡単ではありません。繰り返しますが、私は何を間違っていますか?