2017-03-05 172 views
0

我正在學習Grail,並試圖在代碼之下,但在引用兩個類別的車輛類和模型後,無法啓動應用程序。還我加入一年車輛類整數無法啓動Grail應用程序

Running application... 
2017-03-05 08:48:32.229 ERROR --- [ost-startStop-1] o.s.b.c.embedded.tomcat.TomcatStarter : Error starting Tomcat context. Exception: org.springframework.beans.factory.BeanCreationException. Message: Error creating bean with name 'grailsCacheFilter': Cannot create inner bean '(inner bean)#692e68e0' of type [grails.plugin.cache.web.filter.simple.MemoryPageFragmentCachingFilter] while setting bean property 'filter'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name '(inner bean)#692e68e0': Unsatisfied dependency expressed through method 'setUrlMappingsHandlerMapping' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'urlMappingsHandlerMapping': Unsatisfied dependency expressed through method 'setWebRequestInterceptors' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'openSessionInViewInterceptor': Cannot resolve reference to bean 'hibernateDatastore' while setting bean property 'hibernateDatastore'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateDatastore': Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.grails.orm.hibernate.HibernateDatastore]: Constructor threw exception; nested exception is org.hibernate.MappingException: 
**Could not determine type for: groovy.lang.Binding, at table: vhicle, for columns: [org.hibernate.mapping.Column(binding)]** 
2017-03-05 08:48:32.392 ERROR --- [   main] o.s.boot.SpringApplication    : Application startup failed 

org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.boot.context.embedded.EmbeddedServletContainerException: Unable to start embedded Tomcat 
     at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:137) 
     at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:536) 
     at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) 
org.springframework.boot.SpringApplication.run(SpringApplication.java:315) 
     at grails.boot.GrailsApp.run(GrailsApp.groovy:83) 
     at grails.boot.GrailsApp.run(GrailsApp.groovy:387) 
     at grails.boot.GrailsApp.run(GrailsApp.groovy:374) 
     at grails.boot.GrailsApp$run.call(Unknown Source) 
     at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48) 


FAILURE: Build failed with an exception. 

* What went wrong: 
Execution failed for task ':bootRun'. 
Process 'command '/usr/lib/jvm/java-7-oracle/bin/java'' finished with non-zero exit value 1 

* Try: 
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. 
| Error Failed to start server (Use --stacktrace to see the full trace) 

這裏是我的Vhicle.groovy

 package com.example 

     class Vehicle { 

     Integer year 

     String name 
     Model model 
     Make make 

     static constraints = { 
      year min: 1900 
      name maxSize: 255 
     } 
     } 

     def vehicle = Vehicle.findByName('pickup') 
     if(vehicle) { 
     println vehicle.model // e.g, 'Titan' 
     println vehicle.make // e.g, 'Nissan' 
     } 

     Model.groovy 

     package com.example 

     class Model { 

     String name 

     static belongsTo = [ make: Make ] 

     static constraints = { 
      } 

     String to_String(){ 
      name 
      } 
     } 

     Here is my Make.groovy 

     package com.example 

     class Make { 

      String name 


     static constraints = { 
      } 

      String to_String(){ 
        name 
      } 
      } 

回答

0

由於在異常說:

at table: vhicle 

你拼錯車輛某處

3

檢查您的groovy文件名vehicle.groovy您拼錯了。你寫的類似vhicle.groovy它應該是Vehicle.groovy,因爲類名是Vehicle