grails - 如何将 Grails 2.1 迁移到 Grails 2.3 应用程序?

标签 grails grails-plugin grails-2.0 grails-controller

我正在将我的应用程序从 Grails 2.1 迁移到 2.3。迁移后出现很多错误 - 我想要一些与 Grails 2.3 和 Spring 集成的示例应用程序。

我做了一些 HelloWorld 示例应用程序,它们运行良好。但即使我在我的应用程序中应用了同样的东西,甚至在某些地方它也会出错。因为我的应用程序非常大(100mb)并且我使用了大量与 Spring、Hibernate 和大量 Grails 插件的集成。

我没有找到任何类似“从 Grails 2.1 迁移到 Grails 2.3”的代码级文档。我无法从 Grails 或在线找到任何示例应用程序。

Grails 官方文档,都是关于提供 Grails META 信息的。

在我的 main.gsp 229 行中:

<g:include controller="filter" action="tree"/>

Caused by: org.codehaus.groovy.grails.web.pages.exceptions.GroovyPagesException: Error processing GroovyPageView: Error executing tag <g:include>: Unable to execute include: Request processing failed; nested exception is org.codehaus.groovy.grails.exceptions.GrailsRuntimeException: java.lang.IllegalStateException: Cannot reset buffer after response has been committed
    at org.codehaus.groovy.grails.web.servlet.view.GroovyPageView.createGroovyPageException(GroovyPageView.java:205)
    at org.codehaus.groovy.grails.web.servlet.view.GroovyPageView.handleException(GroovyPageView.java:182)
    at org.codehaus.groovy.grails.web.servlet.view.GroovyPageView.renderWithTemplateEngine(GroovyPageView.java:153)
    at org.codehaus.groovy.grails.web.servlet.view.GroovyPageView.renderMergedOutputModel(GroovyPageView.java:84)
    at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:264)
    at org.codehaus.groovy.grails.web.sitemesh.SpringMVCViewDecorator.render(SpringMVCViewDecorator.java:67)
    ... 51 more
Caused by: org.codehaus.groovy.grails.web.taglib.exceptions.GrailsTagException: Error executing tag <g:include>: Unable to execute include: Request processing failed; nested exception is org.codehaus.groovy.grails.exceptions.GrailsRuntimeException: java.lang.IllegalStateException: Cannot reset buffer after response has been committed
    at org.codehaus.groovy.grails.web.pages.GroovyPage.throwRootCause(GroovyPage.java:531)
    at org.codehaus.groovy.grails.web.pages.GroovyPage.invokeTag(GroovyPage.java:475)
    at sun.reflect.GeneratedMethodAccessor379.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1243)
    at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
    at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
    at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1085)
    at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:1110)
    at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:909)
    at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:989)
    at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:1110)
    at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:909)
    at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:66)
    at mycompany_dev_testuserdev_ws3_myapp_grails_app_views_layouts_main_gsp$_run_closure2.doCall(main.gsp:229)

最佳答案

将您的 Config.groovy 和 BuildConfig.groovy 文件与一个空的新 Grails 2.3 应用程序的默认值进行比较。

最显着的变化是插件依赖项不应再在 application.properties 中描述。您还应该确保您使用的是正确版本的 Grails Tomcat、Hibernate 和 Scaffolding 插件。 Tomcat 和 Hibernate 插件版本不再与 Grails 发布版本相同。 Grails 2.3 中的脚手架功能已被提取到单独的插件中。
还要确保为插件使用正确的范围(为 tomcat 构建,为 hibernate 运行时)。

还建议开始使用新的基于 maven(使用 aether 库,它是 maven 的一部分)依赖项解析。这是通过设置 grails.project.dependency.resolver = "maven" 完成的在 BuildConfig.groovy 中。我在 Grails 2.3 中使用基于 Ivy 的旧解析器遇到了奇怪的类加载问题。

我希望这有帮助。

关于grails - 如何将 Grails 2.1 迁移到 Grails 2.3 应用程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16813031/

相关文章:

ember.js - 在可能保存模型时处理 ember-data 中的自定义服务器端错误

json - 使用自定义转换器时在 Grails 中处理 PUT/POST 请求

mongodb - 在grails 2.3.4中将mongo配置为连接字符串

mysql - 如何在cloudfoundry中执行mysql脚本

grails - Grails插件不能依赖其他Grails插件吗?

mongodb - Grails Audit插件不适用于MongoDB

grails - 如何在 Grails 中实现自引用关系?

linux - Grails 路径不保存

json - Grails GSP安全导航运算符(operator)是否可以防御 “JSONObject$Null”?

hibernate - Hibernate映射在具有别名 “h002-01”的Grails中为列生成错误