1

也许有人可以帮助配置 gradle-tomcat-plugin?

这是build.gradle的内容:

buildscript {
    ext {
        springBootVersion = '1.1.9.RELEASE'
    }
    repositories {
        mavenCentral()
        jcenter()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
        classpath 'com.bmuschko:gradle-tomcat-plugin:2.0'
    }
}

apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'war'
apply plugin: 'spring-boot'
apply plugin: 'com.bmuschko.tomcat'

sourceCompatibility = 1.6
version = '1.0'

repositories {
    mavenCentral()
    jcenter()
}

dependencies {
    def tomcatVersion = '7.0.42'
    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'
    }
}

运行任务 tomcatRun 时出现此错误:无法创建类型为 'TomcatRun' 的任务。这个缩影:

Caused by: java.lang.NoClassDefFoundError: org/codehaus/groovy/runtime/typehandling/ShortTypeHandling
        at com.bmuschko.gradle.tomcat.tasks.Tomcat.<init>(Tomcat.groovy:28)
        at com.bmuschko.gradle.tomcat.tasks.AbstractTomcatRun.<init>(AbstractTomcatRun.groovy)
        at com.bmuschko.gradle.tomcat.tasks.TomcatRun.<init>(TomcatRun.groovy)
        at com.bmuschko.gradle.tomcat.tasks.TomcatRun_Decorated.<init>(Unknown Source)
        at org.gradle.api.internal.DependencyInjectingInstantiator.newInstance(DependencyInjectingInstantiator.java:62)
        at org.gradle.api.internal.ClassGeneratorBackedInstantiator.newInstance(ClassGeneratorBackedInstantiator.java:36)
        at org.gradle.api.internal.project.taskfactory.TaskFactory$1.call(TaskFactory.java:124)
4

2 回答 2

0

如果有人有同样的问题,可能你使用的是gradle而不是gradle wrapper。我通过运行gradlew tomcatRun任务解决了这个问题。

于 2014-11-26T09:23:49.513 回答
0

您至少需要将 Gradle 更新到 2.1 版才能使其正常工作。

于 2015-11-10T16:20:09.443 回答