我已經使用GGTS(IDE)創建了一個Grails項目。我還創建了一個名爲Person
的DOMAIN
類,並將其放在Package結構project.app.domain
內。無法在MVC結構中找到類文件 - 初學者
我還創建了一個Controller
類稱爲PersonController
並把它放在所述封裝結構內project.app.controller
代碼如下:
DOMAIN
//注意:駐留在封裝結構project.app.domain
內部
class Person {
static constraints = {
firstName(blank:false, maxSize:70)
}
int id;
String firstName;
String lastName;
}
控制器
//注意:所在的包結構project.app.controller
class PersonController {
def scaffold = Person
def index() {
render "Hello World"
}
}
內我不認爲Domain
Person
當我說scaffold = Person
當我說的是找不到的。這是我犯的錯誤嗎?如果是這樣,我該如何解決它?
錯誤消息,我得到:
| Error 2014-02-16 12:53:22,754 [FileSystemWatcher: files=#261 [email protected]] ERROR plugins.AbstractGrailsPluginManager - Plugin [controllers:2.2.4] could not reload changes to file [/Users/xxxxxxx/Documents/workspace-ggts-3.4.0.RELEASE/project/grails-app/controllers/project/app/controller/PersonController.groovy]: java.lang.reflect.InvocationTargetException
Message: java.lang.reflect.InvocationTargetException
Line | Method
->> 695 | run in java.lang.Thread
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Caused by InvocationTargetException: null
->> 695 | run in java.lang.Thread
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Caused by MissingMethodException: No signature of method: project.app.controller.PersonController.propertyMissing() is applicable for argument types:() values: []
Possible solutions: propertyMissing(java.lang.String)
->> 695 | run in java.lang.Thread
- - - - - - - - - - - - - - - - - - - -
清潔後
| Error 2014-02-16 13:29:41,651 [Thread-15] ERROR plugins.DefaultGrailsPlugin - Error configuration scaffolding: null
Message: null
Line | Method
->> 695 | run in java.lang.Thread
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Caused by MissingMethodException: No signature of method: project.app.controller.PersonController.propertyMissing() is applicable for argument types:() values: []
Possible solutions: propertyMissing(java.lang.String)
->> 695 | run in java.lang.Thread
你在控制器中有'import project.app.domain.Person'是嗎? –
@Xeon'/ grails-app/domain&/ grails-app/controllers'是在IDE中創建的包。當我使兩個包名稱相同,然後它的作品。但爲什麼我不能像我所做的那樣包含不同的包名? – Illep
你能發佈完整的資源,包括'package'和'imports'語句嗎? –