2014-02-14 35 views
0

每次修改我的代码时,我必须在运行grails run-app之前运行grails clean。如果我不这样做,我得到这样的消息:Grails 2.3.5在每次代码更改后都需要“grails clean”

| 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升级。升级是没有用的(直到这个)。我所要做的就是改变休眠和tomcat版本然后运行grails upgrade; grails clean

任何想法如何,我可以得到它,所以我可以修改代码,只需重新启动使用grails run-app或更好......让重装功能工作,所以当我修改代码时,它会自动编译我刚刚保存的文件(这在Grails 2.2.4中效果很好)。

回答

4

你试过grails -reloading run-app

既然你已经提到你只是在升级过程中改变了插件版本,我想你没有使用分叉模式,默认情况下重新加载是启用的。

看一看Forked Execution and the Reloading Agent。另请注意,在2.3。*中已弃用grails upgrade命令。

+0

这适用于编译在Grails运行时更改的文件,但如果我停止grails并重新启动,我仍然会收到此错误加载驱动程序类。我投了赞成票,但我仍然需要其他答案,因为现在我每次重新启动grails时都必须清理干净。也许我应该提出这两个单独的问题。 – Jason

+0

好的,我知道了!您指向“分叉执行...”的指示使我可以根据您提供的链接中的指示启用分叉执行。启用分叉执行后,我不必在重新启动之间运行'grails clean'。谢谢! – Jason

+0

也为我工作,但请注意,此URL已被更改 - 它目前是http://grails.org/doc/latest/guide/upgradingFrom22.html。 –