Grails 2.3.5 在每次代码更改后都需要“grails clean”
Posted
技术标签:
【中文标题】Grails 2.3.5 在每次代码更改后都需要“grails clean”【英文标题】:Grails 2.3.5 requiring "grails clean" after every code change 【发布时间】:2014-03-13 04:23:45 【问题描述】:每次修改代码时,我都必须先运行grails clean
,然后再运行grails run-app
。如果我不这样做,我会收到这样的消息:
| Error 2014-02-13 16:33:16,774 [localhost-startStop-1] ERROR context.GrailsContextLoader - Error initializing the application: Error creating bean with name 'transactionManagerPostProcessor': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Cannot resolve reference to bean 'dataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource': Cannot resolve reference to bean 'dataSourceUnproxied' while setting bean property 'targetDataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSourceUnproxied': Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'driverClassName' threw exception; nested exception is java.lang.IllegalStateException: Could not load JDBC driver class [oracle.jdbc.OracleDriver]
Message: Error creating bean with name 'transactionManagerPostProcessor': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Cannot resolve reference to bean 'dataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource': Cannot resolve reference to bean 'dataSourceUnproxied' while setting bean property 'targetDataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSourceUnproxied': Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'driverClassName' threw exception; nested exception is java.lang.IllegalStateException: Could not load JDBC driver class [oracle.jdbc.OracleDriver]
Line | Method
->> 262 | run in java.util.concurrent.FutureTask
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 615 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^ 744 | run in java.lang.Thread
这真的很奇怪,因为 Grails 似乎无法加载 Oracle 数据库驱动程序......但如果我运行它加载正常
grails clean
grails run-app
我正在开发的这个应用程序今天从 Grails 2.2.4 升级。升级是无缝的(直到这个)。我所要做的就是更改hibernate和tomcat版本,然后运行grails upgrade; grails clean
任何想法如何获得它,以便我可以修改代码并使用grails run-app
或更好的方式重新启动...让重新加载功能工作,所以当我进行代码修改时,它会自动编译我刚刚保存的文件(这在 Grails 2.2.4 中效果很好)。
【问题讨论】:
【参考方案1】:你试过grails -reloading run-app
吗?
由于您提到您只在升级期间更改了插件版本,我想您没有使用默认启用重新加载的分叉模式。
看看Forked Execution and the Reloading Agent。另请注意,grails upgrade
命令已在 2.3.* 中弃用。
【讨论】:
这适用于编译 Grails 运行时更改的文件,但如果我停止 grails 并重新启动,我仍然会收到此错误加载驱动程序类。我对此投了赞成票,但我仍然需要另一个答案,因为现在我每次重新启动 grails 时都必须进行清理。也许我应该提出这两个单独的问题。 好的,我搞定了!您指向“分叉执行...”的指针使我根据您提供的链接中的说明启用分叉执行。启用分叉执行后,我不再需要在重新启动之间运行grails clean
。谢谢!
也为我工作过,但请注意 URL 已更改 - 目前为 grails.org/doc/latest/guide/upgradingFrom22.html。
我遇到了同样的问题,我从 grails 2.2.4 升级到 grails 2.3.11,之后我每次都必须运行 grails clean,否则它找不到我的 Informix 数据库驱动程序。启用分叉模式也为我修复了它。我找不到合理的解释为什么会这样。以上是关于Grails 2.3.5 在每次代码更改后都需要“grails clean”的主要内容,如果未能解决你的问题,请参考以下文章
Grails:部署时间非常慢。 'Resolving Dependencies...' 需要 10 多秒