我继承了一个基于 Grails 2.5.4 的多模块 grails 应用程序。
它工作得很好,但我需要升级到 3.x。
我安装了groovy 3.0.4和grails 3.3.11,并根据官网提供的教程(https://docs.grails.org/3.0.x/guide/upgrading.html)完成了grails升级任务。
当我尝试构建项目时,我面临多个与基类相关的“无法解决类”问题,例如:
Starting a Gradle Daemon (subsequent builds will be faster)
:compileAstJava NO-SOURCE
:compileAstGroovy NO-SOURCE
:processAstResources NO-SOURCE
:astClasses UP-TO-DATE
:compileJava NO-SOURCE
:configScript
:compileGroovy
startup failed:
C:\repo\upgraded-app\myapp-core\grails-app\domain\bittt\holders\Exclusion.groovy: 5: unable to resolve class org.grails.databinding.BindingFormat
@ line 5, column 1.
import org.grails.databinding.BindingFormat
^
C:\repo\upgraded-app\myapp-core\grails-app\domain\bittt\migration\CustomsLgcy.groovy: 5: unable to resolve class org.postgresql.core.Query
@ line 5, column 1.
import org.postgresql.core.Query
^
C:\repo\upgraded-app\myapp-core\grails-app\services\bittt\ExclusionService.groovy: 13: unable to resolve class org.grails.web.servlet.mvc.GrailsParameterMap
@ line 13, column 1.
import org.grails.web.servlet.mvc.GrailsParameterMap
^
C:\repo\upgraded-app\myapp-core\grails-app\services\bittt\NotificationService.groovy: 12: unable to resolve class org.grails.commons.GrailsApplication
@ line 12, column 1.
import org.grails.commons.GrailsApplication
^
...
我的 myapp.core build.gradle 文件包含以下内容:buildscript {
repositories {
mavenLocal()
maven { url "https://repo.grails.org/grails/core" }
}
dependencies {
classpath "org.grails:grails-gradle-plugin:$grailsVersion"
classpath "org.grails.plugins:hibernate5:${gormVersion-".RELEASE"}"
classpath "com.bertramlabs.plugins:asset-pipeline-gradle:2.15.1"
}
}
version "0.1"
group "myapp.core"
apply plugin:"eclipse"
apply plugin:"idea"
apply plugin:"war"
apply plugin:"org.grails.grails-plugin"
apply plugin:"org.grails.grails-plugin-publish"
apply plugin:"asset-pipeline"
apply plugin:"org.grails.grails-gsp"
repositories {
mavenLocal()
maven { url "https://repo.grails.org/grails/core" }
}
dependencies {
compile "org.springframework.boot:spring-boot-starter-logging"
compile "org.springframework.boot:spring-boot-autoconfigure"
compile "org.grails:grails-core"
compile "org.springframework.boot:spring-boot-starter-actuator"
compile "org.springframework.boot:spring-boot-starter-tomcat"
compile "org.grails:grails-web-boot"
compile "org.grails:grails-logging"
compile "org.grails:grails-plugin-rest"
compile "org.grails:grails-plugin-databinding"
compile "org.grails:grails-plugin-i18n"
compile "org.grails:grails-plugin-services"
compile "org.grails:grails-plugin-url-mappings"
compile "org.grails:grails-plugin-interceptors"
compile "org.grails.plugins:cache"
compile "org.grails.plugins:async"
compile "org.grails.plugins:scaffolding"
compile "org.grails.plugins:events"
compile "org.grails.plugins:hibernate5"
compile "org.hibernate:hibernate-core:5.1.16.Final"
compile "org.grails.plugins:gsp"
compile 'org.grails.plugins:spring-security-core:3.2.3'
compile 'org.grails.plugins:spring-security-acl:3.2.1'
compile "org.grails.plugins:phonenumbers:0.10"
console "org.grails:grails-console"
profile "org.grails.profiles:web-plugin"
provided "org.grails:grails-plugin-services"
provided "org.grails:grails-plugin-domain-class"
runtime "org.glassfish.web:el-impl:2.1.2-b03"
runtime "com.h2database:h2"
runtime "org.apache.tomcat:tomcat-jdbc"
runtime "com.bertramlabs.plugins:asset-pipeline-grails:2.15.1"
testCompile "org.grails:grails-gorm-testing-support"
testCompile "org.grails.plugins:geb"
testCompile "org.grails:grails-web-testing-support"
testCompile "org.grails.plugins:geb:1.1.2"
testRuntime "org.seleniumhq.selenium:selenium-htmlunit-driver:2.47.1"
testRuntime "net.sourceforge.htmlunit:htmlunit:2.18"
testRuntime "org.seleniumhq.selenium:selenium-chrome-driver:2.47.1"
}
bootRun {
jvmArgs('-Dspring.output.ansi.enabled=always')
addResources = true
String springProfilesActive = 'spring.profiles.active'
systemProperty springProfilesActive, System.getProperty(springProfilesActive)
}
tasks.withType(Test) {
systemProperty "geb.env", System.getProperty('geb.env')
systemProperty "geb.build.reportsDir", reporting.file("geb/integrationTest")
systemProperty "webdriver.chrome.driver", System.getProperty('webdriver.chrome.driver')
systemProperty "webdriver.gecko.driver", System.getProperty('webdriver.gecko.driver')
}
assets {
minifyJs = true
minifyCss = true
}
我真的不明白为什么我会收到这些错误,因为相关的依赖项似乎已经到位......我在这里遗漏了什么?谢谢 :)
最佳答案
C:\repo\upgraded-app\myapp-core\grails-app\domain\bittt\holders\Exclusion.groovy: 5: unable to resolve class org.grails.databinding.BindingFormat @ line 5, column 1. import org.grails.databinding.BindingFormat
在 Grails 3.3.11 中,包是
grails.databinding
,而不是 org.grails.databinding
(https://github.com/grails/grails-core/blob/v3.3.11/grails-databinding/src/main/groovy/grails/databinding/BindingFormat.java)。软件包名称也更改为 org.grails.web.servlet.mvc.GrailsParameterMap
( https://github.com/grails/grails-core/blob/v3.3.11/grails-web-common/src/main/groovy/grails/web/servlet/mvc/GrailsParameterMap.java ) 和 import org.grails.commons.GrailsApplication
(https://github.com/grails/grails-core/blob/v3.3.11/grails-core/src/main/groovy/grails/core/GrailsApplication.java)。org.postgresql.core.Query
是一个单独的问题。看起来您的项目没有表达对 postgres 库的依赖关系,因此该类对应用程序不可用。
关于grails - *从 grails 2.5.4 升级到 grails 3.3.11 时出现“无法解决类”问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63887042/