2011-08-06 2 views
1
에서 ClassCastException이 오류를 가지고

나는 내가 다음과 같은 오류가 발생했습니다Grails의 2.0 분사 콩 및 컨트롤러

class MyController { 
    def db 
    index() { 
    } 
} 

정의하는 모든 컨트롤러

beans = { 
    db(my.DatabaseRepo) { singleton true } 
} 

에 주입하기 위해 다음 콩을

java.lang.ClassCastException: my.DatabaseRepo cannot be cast to groovy.lang.Closure 
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) 
    at java.lang.Thread.run(Thread.java:680) 

답변

1

이것은 http://jira.grails.org/browse/GRAILS-7800이며 고정되어 M2에서는 문제가되지 않습니다. 임시 해결 방법으로 'def'대신에 빈 클래스를 가져 와서 명시 적으로 입력하면됩니다.

import my.DatabaseRepo 

class MyController { 

    DatabaseRepo db 

    index() { 
    } 
}