简体   繁体   English

如何为现有应用程序升级Grails版本?

[英]How do I upgrade the Grails version for an existing application?

I have an example Grails application (from Grails in Action) that was created a while ago under version 1.1.1 on a different PC. 我有一个Grails应用程序示例(来自Grails in Action),该应用程序是在另一台PC上以1.1.1版创建的。

I am now loading Grails 1.2.0 and want to revisit the app. 我现在正在加载Grails 1.2.0,并希望重新访问该应用程序。 However, when I try to run it I get this message: 但是,当我尝试运行它时,出现以下消息:

Application expects grails version [1.1.1], but GRAILS_HOME is version [1.2.0] - use the correct Grails version or run 'grails upgrade' if this Grails version is newer than the version your application expects. 应用程序期望使用grails版本[1.1.1],但是GRAILS_HOME是版本[1.2.0]-使用正确的Grails版本或如果该Grails版本比应用程序期望的版本新,请运行“ grails upgrade”。

After reading around a bit I cleared out the 1.2.0 folder under .grails in my home directory (from previous attempts while exploring the issue), ran "grails clean" and "grails upgrade" (answering "y" where prompted). 阅读了一番后,我清除了主目录中.grails下的1.2.0文件夹(从以前的尝试中浏览该问题),然后运行“ grails clean”和“ grails upgrade”(在出现提示时回答“ y”)。

However, I consistently get "Invalid duplicate class definition" conflicts between classes in \\grails\\qotd\\src\\java and \\grails\\qotd\\grails-app{controllers,services,conf}. 但是,我在\\ grails \\ qotd \\ src \\ java和\\ grails \\ qotd \\ grails-app {controllers,services,conf}中的类之间始终遇到“无效的重复类定义”冲突。

Are there any additional manual steps that I need to perform? 我还需要执行其他手动步骤吗?

I understood your problem. 我了解您的问题。 The solution is just modify the grails vesion to 1.2.0 in application.properties file in your application 解决方案是将应用程序中application.properties文件中的grails vesion修改为1.2.0

If, as you pointed out in the comments, your /src/java contains .groovy files - that could definitely cause unexpected behavior. 如您在注释中指出的,如果/ src / java包含.groovy文件-肯定会导致意外行为。 I haven't hit your particular issue, but any time I had a .groovy file mismatched with the class name inside it, I'd get strange compilation issues - so I guess you could be having a similar issue. 我还没有解决您的特定问题,但是任何时候只要我的.groovy文件与其中的类名不匹配,我都会遇到奇怪的编译问题-因此我想您可能也遇到了类似的问题。

If you have files / classes with the same names in two locations, that's the likely culprit. 如果您在两个位置具有相同名称的文件/类,则可能是罪魁祸首。 If you have .groovy files in /src/java, that's another potential source. 如果/ src / java中有.groovy文件,则这是另一个潜在来源。

Also, putting BootStrap, Config, DataSource and URLMappings into /src/java, that's another potential source of issues. 另外,将BootStrap,Config,DataSource和URLMappings放入/ src / java,这是另一个潜在的问题根源。 I'd clear out your /src/java by making sure all the files are in their appropriate places under grails-app. 我将通过确保所有文件都位于grails-app下的适当位置来清理/ src / java。

You can upgrade grails version with 5 steps 您可以通过5个步骤升级grails版本

  1. Project -> Clean 项目->清洁
  2. application.properties -> Change app.grails.version application.properties->更改app.grails.version
  3. Your project -> Properties -> Grails -> Change grails installation to new grails version. 您的项目->属性-> Grails->将grails安装更改为新的grails版本。
  4. Your project -> Grails tools -> Refresh Dependencies 您的项目-> Grails工具->刷新依赖项

I think this may be help you 我认为这可能对您有帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM