提供者org.jetbrains.plugins.gradle.tooling.builder.WarModelBuilderImpl无法实例化

时间:2019-03-12 11:54:50

标签: gradle intellij-idea

我正在编写Pro Spring MVC:With Web Flow这本书的示例代码。

但是,当我尝试导入Gradle项目时收到以下错误:

原因:org.jetbrains.plugins.gradle.tooling.ModelBuilderService:提供程序org.jetbrains.plugins.gradle.tooling.builder.WarModelBuilderImpl无法实例化

这是父项目的build.gradle文件:

apply plugin: 'base'

ext.springVersion = '3.2.3.RELEASE'
ext.tilesVersion = '2.2.2'
ext.springSecurityVersion = '3.1.4.RELEASE'
ext.springSwfVersion = '2.3.2.RELEASE'
ext.hibernateVersion = '4.2.3.Final'
ext.hibernateValidatorVersion = '5.0.1.Final'
ext.ehCacheVersion = '2.7.2'
ext.aspectJVersion = '1.7.3'

ext.tomcatVersion = '7.0.42'
ext.cargoVersion = '1.3.3'

ext.webProjects = subprojects.findAll { project -> project.name.endsWith('bookstore') }

buildscript {
    repositories {
        maven { url 'http://jcenter.bintray.com/' }
    }

    dependencies {
        classpath 'org.gradle.api.plugins:gradle-tomcat-plugin:1.2.4'
        classpath 'org.gradle.api.plugins:gradle-cargo-plugin:1.5'
    }
}

allprojects {

    description = 'Bookstore Sample Application'

    group = 'com.apress.prospringmvc'

    version = '1.0.0'

    repositories {
        mavenRepo url: 'http://maven.springframework.org/release'
        mavenRepo url: 'http://maven.springframework.org/snapshot'
        mavenCentral()
        mavenRepo url: 'http://maven.springframework.org/milestone'
        mavenRepo url: 'https://repository.jboss.org/nexus/content/repositories/releases/'
        mavenRepo url: 'http://download.java.net/maven/glassfish/org/glassfish/'
    }

    tasks.withType(Compile) {
        options.compilerArgs << "-g"
    }
}

configure(webProjects) {
    apply plugin: 'war'
    apply plugin: 'jetty'
    apply plugin: 'tomcat'
    apply plugin: 'cargo'

    dependencies() {
        compile project(':bookstore-shared'), project(':bookstore-web-resources')

        compile "org.apache.tiles:tiles-servlet:$tilesVersion"
        compile "org.apache.tiles:tiles-jsp:$tilesVersion"
        compile "org.apache.tiles:tiles-api:$tilesVersion"
        compile "org.apache.tiles:tiles-core:$tilesVersion"

        runtime "jstl:jstl:1.2"

        providedCompile 'javax.servlet:javax.servlet-api:3.0.1'

        tomcat "org.apache.tomcat.embed:tomcat-embed-core:${tomcatVersion}",
                "org.apache.tomcat.embed:tomcat-embed-logging-juli:${tomcatVersion}"
        tomcat("org.apache.tomcat.embed:tomcat-embed-jasper:${tomcatVersion}") {
            exclude group: 'org.eclipse.jdt.core.compiler', module: 'ecj'

            cargo "org.codehaus.cargo:cargo-core-uberjar:${cargoVersion}",
                    "org.codehaus.cargo:cargo-ant:${cargoVersion}"
        }
    }

    cargo {
        containerId = 'tomcat7x'
        port = 8080

        local {
            homeDir = file('container/apache-tomcat-7.0.42')
            output = file('container/apache-tomcat-7.0.42/output.log')
        }
    }

    war {
        version = '' //We do this to make the wars versionless, when they are deployed with cargo, the context
        //root of the app is equal to the file name, which is equal to the sample directory name.
    }

    task systemTest(type: Test) {
        include '**/*FrontendTest.*'
        dependsOn(war)

        doFirst {
            cargoStartLocal.execute()
        }
    }

    test {
        exclude '**/*FrontendTest.*'
    }

}


subprojects() {
    apply plugin: 'java'
    apply plugin: 'eclipse-wtp'
    apply plugin: 'idea'

    sourceCompatibility = 1.7
    targetCompatibility = 1.7

    dependencies() {
        compile "org.springframework:spring-orm:$springVersion"
        compile "org.springframework:spring-aop:$springVersion"
        compile "org.springframework:spring-webmvc:$springVersion"
        compile "org.springframework:spring-oxm:$springVersion"

        compile 'org.slf4j:jcl-over-slf4j:1.7.2'
        compile 'ch.qos.logback:logback-classic:1.0.9'
        compile 'org.apache.commons:commons-lang3:3.0.1'
        compile 'com.thoughtworks.xstream:xstream:1.4.2'
        compile 'com.h2database:h2:1.3.168'
        compile 'cglib:cglib-nodep:2.2.2'
        compile "org.aspectj:aspectjrt:$aspectJVersion"
        compile "org.aspectj:aspectjweaver:$aspectJVersion"

        compile "org.hibernate:hibernate-entitymanager:$hibernateVersion"
        compile "org.hibernate:hibernate-core:$hibernateVersion"
        compile "org.hibernate:hibernate-ehcache:$hibernateVersion"
        compile "org.hibernate:hibernate-validator:$hibernateValidatorVersion"
        compile "net.sf.ehcache:ehcache:$ehCacheVersion"

        compile 'com.lowagie:itext:2.1.7'
        compile 'net.sourceforge.jexcelapi:jxl:2.6.12'
        compile 'org.codehaus.jackson:jackson-mapper-asl:1.9.11'
        compile 'commons-codec:commons-codec:1.6'
        compile 'joda-time:joda-time:2.1'

        testCompile 'junit:junit:4.11'
        testCompile "org.springframework:spring-test:$springVersion"
    }

    eclipse {
        project.natures "org.springframework.ide.eclipse.core.springnature"
    }

}

task wrapper(type: Wrapper) { gradleVersion = '1.6' }

我该怎么办?

1 个答案:

答案 0 :(得分:0)

提升gradle版本是我目前唯一的解决方案; 4.0应该可以工作:

更改:

task wrapper(type: Wrapper) { gradleVersion = '1.6' }

收件人:

task wrapper(type: Wrapper) { gradleVersion = '4.0' }

我正在尝试以其他方式解决它,直到目前为止使用1.7-失败。