Grails:应用程序 运行 时的 CLI 交互

Grails: CLI interaction while application is running

在应用程序 运行 时通过命令行与 Grails 交互有什么不好的地方吗?例如,我通过 grails run-app 目标在本地计算机上有一个应用程序 运行,然后我打开另一个命令提示符并创建了一个域 class,我注意到它创建了域 class 和等效测试 class 但在我有应用程序的另一个终端 运行 我得到了相当多的红色文本,如下所示:

    | Error 2015-03-01 10:40:10,392 [Thread-10] ERROR plugins.AbstractGrailsPluginManager
  - Plugin [domainClass:2.3.8] could not reload changes to file [C:\Users\user\Dropbo
x\MoeStuff\Projects\qotd\grails-app\domain\qotd\Quote.groovy]: Ambiguous method overl
oading for method grails.spring.BeanBuilder#registerBeans.
Cannot resolve which method to invoke for [null] due to overlapping prototypes betwee
n:
        [interface org.codehaus.groovy.grails.commons.spring.RuntimeSpringConfigurati
on]
        [interface org.springframework.beans.factory.support.BeanDefinitionRegistry]
Message: Ambiguous method overloading for method grails.spring.BeanBuilder#registerBe
ans.
Cannot resolve which method to invoke for [null] due to overlapping prototypes betwee
n:
        [interface org.codehaus.groovy.grails.commons.spring.RuntimeSpringConfigurati
on]
        [interface org.springframework.beans.factory.support.BeanDefinitionRegistry]
    Line | Method
->> 3034 | chooseMostSpecificParams     in groovy.lang.MetaClassImpl
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|   2986 | chooseMethodInternal         in     ''
|   2929 | chooseMethod . . . . . . . . in     ''
|   1204 | getMethodWithCachingInternal in     ''
|   3163 | createPogoCallSite . . . . . in     ''
|   1306 | createPogoCallSite           in groovy.lang.ExpandoMetaClass
|    147 | createPogoSite . . . . . . . in org.codehaus.groovy.runtime.callsite.CallS
iteArray
|    161 | createCallSite               in     ''
|     45 | defaultCall . . . . . . . .  in     ''
|    108 | call                         in org.codehaus.groovy.runtime.callsite.Abstr
actCallSite
|    116 | call . . . . . . . . . . . . in     ''
|    156 | doCall                       in org.codehaus.groovy.grails.plugins.DomainC
lassGrailsPlugin$_closure3
|     -2 | invoke0 . . . . . . . . . .  in sun.reflect.NativeMethodAccessorImpl
|     57 | invoke                       in     ''
|     43 | invoke . . . . . . . . . . . in sun.reflect.DelegatingMethodAccessorImpl
|    606 | invoke                       in java.lang.reflect.Method
|   1254 | jlrMethodInvoke . . . . . .  in org.springsource.loaded.ri.ReflectiveInter
ceptor
|     90 | invoke                       in org.codehaus.groovy.reflection.CachedMetho
d
|    233 | doMethodInvoke . . . . . . . in groovy.lang.MetaMethod
|   1086 | invokeMethod                 in groovy.lang.MetaClassImpl
|   1110 | invokeMethod . . . . . . . . in groovy.lang.ExpandoMetaClass
|    910 | invokeMethod                 in groovy.lang.MetaClassImpl
|    411 | call . . . . . . . . . . . . in groovy.lang.Closure
|    767 | invokeOnChangeListener       in org.codehaus.groovy.grails.plugins.Default
GrailsPlugin
|    716 | notifyOfEvent . . . . . . .  in     ''
|    731 | notifyOfEvent                in     ''
|    409 | informOfClassChange . . . .  in org.codehaus.groovy.grails.plugins.Abstrac
tGrailsPluginManager
|    367 | informOfFileChange           in     ''
|    243 | informPluginManager . . . .  in org.codehaus.groovy.grails.compiler.Grails
ProjectWatcher
|     46 | access0                   in     ''
|    169 | onNew . . . . . . . . . . .  in org.codehaus.groovy.grails.compiler.Grails
ProjectWatcher
|    210 | cacheFilesForDirectory       in org.codehaus.groovy.grails.compiler.Direct
oryWatcher
|    204 | cacheFilesForDirectory . . . in     ''
|    187 | checkForNewFiles             in     ''
|    163 | run . . . . . . . . . . . .  in     ''
^    178 | run                          in org.codehaus.groovy.grails.compiler.Grails
ProjectWatcher

任何人都可以谈谈这个错误的含义吗?做我一开始做的事情是否可以,或者我应该总是在向 grails 发出任何与 artefact creation/modification 相关的命令或与 CLI 交互之前从 运行 停止应用程序圣杯?谢谢

最佳做法是在创建工件时停止您的应用程序。只要您不对 class 层次结构进行重大修改,您通常可以通过保留应用程序 运行 来进行修改。

原因是在开发模式下,Grails 会监视更改工件并尝试重新加载这些更改。在创建的情况下,它可能会在错误的时间命中并混淆您的应用程序(您在问题中看到的内容)。

重新加载 changed/new 资源(尤其是域 classes)并不完美,但大部分时间都可以。在创建过程中停止您的应用程序,省去您的麻烦。

因此 grails 将尝试编译并加载对文件的更改。所以你在这里看到的是 grails 试图编译你修改过的文件或正在修改的文件,但失败了。

现在,grails 加载和编译更改的效果如何,有些成败。它会加载它们,但有时它只是不起作用并且需要重新启动服务器。此外,观看文件所需的处理器数量可能会过载,尤其是当您在服务器处于 运行.

时检出新代码时

那么这有什么害处吗?好吧,不,它可能会或可能不会工作。您的服务器可能不会反映更改,或者它可能会给您错误的响应而不是代码所说的,因为它无法加载该代码。更改域对象可能会影响您的数据库或持久层,但某些更改可能与您的数据库不兼容,因此您必须停止它。