无法解析类 org.grails.databinding.converters.web.LocaleAwareNumberConverter
@ 第 3 行,第 1 列。
导入 org.grails.databinding.converters.web.LocaleAwareNumberConverter
这发生在我将 grails 从 2.2.4 升级到 3.1.3 时
我是否缺少 build.gradle 中的依赖项?
我遵循了这个文档 http://docs.grails.org/3.1.1/api/index-all.html我发誓我正在导入正确的类(class)。甚至看起来像基于这个https://github.com/grails/grails-core/blob/master/grails-plugin-databinding/src/main/groovy/org/grails/databinding/converters/web/LocaleAwareNumberConverter.groovy
我错过了什么?这不是 LocaleAwareNumberConverter 的正确导入吗?
import org.grails.databinding.converters.web.LocaleAwareNumberConverter
这是我的 build.gradle
description = 'Internal Tools'
ext {
grailsVersion = "3.1.3"
}
apply plugin: "org.grails.grails-web"
apply plugin: "war"
apply plugin:"org.grails.grails-gsp"
grails {
grailsVersion = "3.1.3"
// springLoadedVersion = '1.2.4.RELEASE'
}
configurations.all {
// already provided by the JVM, Grails complains if classes show up twice in the classpath
exclude group: 'xml-apis', module: 'xml-apis'
exclude module: 'grails-plugin-log4j'
//provided servlet container
exclude group: 'javax.el', module: 'el-api'
exclude group: 'org.glassfish.web', module: 'el-impl'
}
dependencies {
compile project(':business-logic')
// test(project(path: ':business-logic', configuration: 'testArtifacts'))
def slf4jVersion = '1.7.2'
compile "org.slf4j:jcl-over-slf4j:${slf4jVersion}"
compile "org.slf4j:jul-to-slf4j:${slf4jVersion}"
compile "org.slf4j:slf4j-api:${slf4jVersion}"
// We force a newer version of Ant to work around a bug in the Oracle JRE. This can be removed when Grails upgrades Ant
// See Ant 'Bug 54641' for more details
runtime "org.apache.ant:ant:1.9.2"
runtime "org.apache.ant:ant-junit:1.9.2"
// Grails
runtime "org.grails:grails-dependencies:$grailsVersion"
compile "org.grails:grails-plugin-validation:3.1.3"
compile 'org.grails.plugins:converters:4.0.0'
compile 'org.grails.plugins:gorm-tools:6.1.11-v.12'
compile "org.grails:grails-core"
compile "org.grails.plugins:hibernate4"
compile "org.hibernate:hibernate-core:4.3.11.Final"
compile "org.hibernate:hibernate-ehcache:4.3.11.Final"
// Grails plugins
compile "org.grails.plugins:hibernate4:6.+"
compile "org.grails.plugins:tomcat:7.0.+"
compile "org.grails.plugins:export:1.6"
compile "org.grails.plugins:webflow:2.1.0"
compile 'org.grails.plugins:logback:0.3.1'
runtime "org.grails:grails-plugin-validation:$grailsVersion"
// test "org.grails:grails-test:$grailsVersion"
// test "org.grails:grails-plugin-testing:$grailsVersion"
// test 'org.hamcrest:hamcrest-all:1.1'
// test 'org.mockito:mockito-all:1.8.0'
// test 'nekohtml:nekohtml:1.9.6.2'
// bootstrap 'ch.qos.logback:logback-classic:1.1.3'
}
test {
doFirst {
tasks.getByPath(':dbTestCreate').ext.testDatabase.create()
}
dependsOn(':configProperties')
jvmArgs '-XX:MaxMetaspaceSize=256m'
systemProperty 'main.conf.file', "$configOutputDir/main_test.properties"
String protocol = "file:"
systemProperty 'logback.configurationFile', protocol + new File(rootProject.projectDir,"dev/log/logback.xml").getAbsolutePath()
}
bootRun {
dependsOn(':configProperties', ':dbValidate')
jvmArgs '-XX:MaxMetaspaceSize=256m'
systemProperty 'main.conf.file', "$configOutputDir/main_dev.properties"
String protocol = "file:"
systemProperty 'logback.configurationFile', protocol + new File(rootProject.projectDir,"dev/log/logback.xml").getAbsolutePath()
}
war {
String protocol = "file:"
// systemProperty 'logback.configurationFile', protocol + new File(rootProject.projectDir,"dev/log/logback.xml").getAbsolutePath()
}
// We re-package the war so it will include the extra GradleCM meta-info.
// We use a zip task rather than a war task because the war task adds extra files such as a second web.xml
task reWar(type: Zip, dependsOn: ['war']) {
destinationDir = file("$buildDir/libs")
extension = 'war'
// HACK: the input needs to be wrapped in a closure so it is evaluated lazily. This is because the 'war' task output
// file changes once the version is set
from { zipTree(war.archiveName) }
//
// Build info file
//
from (rootProject.buildinfo.filedir) {
include rootProject.buildinfo.filename
into 'META-INF'
}
}
artifacts {
archives reWar
}
// Ensure tests are run for uploadArchives
uploadArchives.dependsOn('check')
buildscript {
repositories {
maven { url "https://repo1.maven.org/maven2/" }
maven { url "https://dl.bintray.com/jfrog/jfrog-jars/" }
maven { url "https://repo.gradle.org/gradle/libs-releases-local/" }
maven { url "https://repo.spring.io/plugins-release/" }
maven { url "https://repo.maven.apache.org/maven2/" }
maven { url "https://repo.grails.org/grails/core" }
mavenCentral()
}
dependencies {
classpath "org.grails:grails-gradle-plugin:3.1.3"
classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:1.+"
classpath "org.gradle:gradle-tooling-api:5.+"
classpath "org.codehaus.groovy.modules.http-builder:http-builder:0.7.+"
classpath "org.grails.plugins:hibernate4:${gormVersion-".RELEASE"}"
}
}
最佳答案
见 https://github.com/grails/grails-core/blob/6789d6233745e0fdf53541c107a6220aa570d9c3/grails-plugin-databinding/src/main/groovy/org/grails/plugins/databinding/DataBindingGrailsPlugin.groovy#L32 .该代码在 Grails 3.1.3 中并且工作正常。
该类(class)在grails-plugin-databinding
模块。如果该库在编译时位于您的依赖关系图中,则导入将起作用。
Am I missing a dependency in my build.gradle?
没有看到你的
build.gradle
就不可能这么说.
关于gradle - 升级到 grails 3.1.13,现在无法解析类 org.grails.databinding.converters.web.LocaleAwareNumberConverter,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59414933/