我使用Grails 3.0.7和數據庫遷移插件。我有超級簡單的遷移,我不能去工作:Grails 3 with database-migration插件:類[com.mypackage.security.RequestMap]上的方法在Grails應用程序之外使用
databaseChangeLog = {
changeSet(id: '20150926BaseSecurityConfig', author: 'me') {
grailsChange {
change {
new RequestMap('/home', 'permitAll').save(failOnError: true, flush: true)
}
}
}
}
這就是它的全部。我有類似的遷移工作在運行Grails 2.3.7的另一個項目中,沒有任何問題。在這裏,我得到這個異常:
Caused by: java.lang.IllegalStateException: Method on class [com.mysite.security.RequestMap] was used outside of a Grails application. If running in the context of a test using the mocking API or bootstrap Grails correctly.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
另外,如果我把new RequestMap
線BootStrap.groovy
,它保存得很好。我不確定這裏有什麼問題。
你能提供你的'DataSource.groovy'配置? –
另外,你的hibernate插件版本是什麼? –
你使用grails-3的插件嗎?請記住,在頁面'https:// grails.org/plugins /'是grails 1和2的插件。 爲grails-3準備的插件在這裏是https:// bintray.com/grails/plugins' –