在我的應用程序中,我有一個grails域類Student。我在src.java中也有幾個類,最初是用普通的java編寫的。來自java源的Grails域類方法錯誤:找不到符號
在某些方法的類,我試圖讓學生喜歡這個集合中的一個:
this.students = new ArrayList<Student>(Student.findAll());
Grails的包是進口的,的IntelliJ不抱怨,但我得到foolwing錯誤,而試圖編譯。
[groovyc] org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
[groovyc] Compile error during compilation with javac.
[groovyc] F:\path\ProjectName\src\java\grb\StudentSchedule.java:58: error: cannot find symbol
[groovyc] this.students = new ArrayList<Student>(Student.findAll());
[groovyc] ^
[groovyc] symbol: method findAll()
[groovyc] location: class Student
我一直在嘗試不同的方法,對學生,但都給了我同樣的錯誤 - 找不到符號。
Grails向所有域類動態添加'findAll()'方法。所以調用方法依賴於Groovy的動態調度來查找方法,然後執行它。因爲該方法本身不存在,所以不能直接從Java調用它。 –
Emmanuel,感謝您的評論!有什麼方法可以解決問題嗎? –
在groovy而不是Java中編寫這些類 –