2014-02-16 125 views
0

我已經使用GGTS(IDE)創建了一個Grails項目。我還創建了一個名爲PersonDOMAIN類,並將其放在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" 
    } 
} 

內我不認爲DomainPerson當我說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 
+0

你在控制器中有'import project.app.domain.Person'是嗎? –

+0

@Xeon'/ grails-app/domain&/ grails-app/controllers'是在IDE中創建的包。當我使兩個包名稱相同,然後它的作品。但爲什麼我不能像我所做的那樣包含不同的包名? – Illep

+0

你能發佈完整的資源,包括'package'和'imports'語句嗎? –

回答

1

能否請您嘗試運行的Grails clean命令,然後嘗試再次啓動的Grails應用程序?

grails clean 
+0

仍然沒有運氣。清潔後,我收到一些其他的錯誤信息。我已將它添加到我的帖子上面。 – Illep

+0

你可以嘗試用這個 **靜態腳手架= true ** –

+0

替換腳手架代碼(** def scaffold = Person **)你也可以嘗試重新啓動IDE –