无法启动Grail应用程序

时间:2017-03-05 10:26:56

标签: grails groovy

我正在学习Grail,并且正在尝试使用以下代码但是在引用车辆类中的两个类make和model之后无法启动应用程序。我也在车辆类中添加年份作为整数

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
            }
          }

2 个答案:

答案 0 :(得分:4)

检查您错误拼写的常规文件名vehicle.groovy。您写的内容与vhicle.groovy类似Vehicle.groovy,因为类名为Vehicle

答案 1 :(得分:0)

正如它在例外中所说:

at table: vhicle

你在某个地方拼错了车辆