gpt4 book ai didi

tomcat - gradle-tomcat-plugin `Could not create task of type ' TomcatRun'`

转载 作者:行者123 更新时间:2023-11-28 21:58:27 25 4
gpt4 key购买 nike

我有一个具有多项目结构的项目。

project
subproject1
subproject2
....

在我的 main 项目中,我添加了一些通用依赖项,在 subproject 中,我添加了特定的依赖项。

我的主要项目build.gradle

apply plugin: 'eclipse'
apply plugin: 'java'

allprojects {
group = 'com.app.pmc'
}

subprojects {
apply plugin: 'java'
apply plugin: 'eclipse'
repositories {
mavenCentral()
}
dependencies {
testCompile 'junit:junit:4.11'
}
}

buildscript {
repositories {
mavenCentral()
jcenter()
}

dependencies {
classpath 'net.saliman:gradle-liquibase-plugin:1.0.0'
classpath 'net.saliman:groovy-liquibase-dsl:1.0.0'
classpath 'org.postgresql:postgresql:9.3-1102-jdbc41'
classpath 'com.bmuschko:gradle-tomcat-plugin:2.0'
}
}

有一个创建网络应用程序的子项目。我的这个项目的 build.gradle 文件如下所示

apply plugin: 'war'
apply plugin: 'com.bmuschko.tomcat'

dependencies {
compile project(':subproject-service')

compile 'org.springframework:spring-core:4.1.1.RELEASE'
compile 'org.springframework:spring-context:4.1.1.RELEASE'
compile 'org.springframework:spring-webmvc:4.1.1.RELEASE'

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

tomcat {
httpPort = 8080
httpsPort = 8081
}

}

然而,当我尝试在我的子项目文件夹中运行 gradle tR 时 - 我遇到了错误

FAILURE: Build failed with an exception.

* Where:
Build file 'D:\project\subproject-web\build.gradle' line: 2

* What went wrong:
A problem occurred evaluating project ':subproject-web'.
> Could not create task of type 'TomcatRun'.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

有什么问题?

最佳答案

首先,在dependencies block 中定义tomcat 配置闭包是无效的。其次,您还有一个无效的依赖项(logginlogging):

tomcat "org.apache.tomcat.embed:tomcat-embed-logging-juli:${tomcatVersion}"

您可以在下面找到一个有效的脚本:

buildscript {
repositories {
mavenCentral()
jcenter()
}

dependencies {
classpath 'com.bmuschko:gradle-tomcat-plugin:2.0'
}
}

apply plugin: 'war'
apply plugin: 'com.bmuschko.tomcat'

repositories {
mavenCentral()
jcenter()
}

dependencies {
compile 'org.springframework:spring-core:4.1.1.RELEASE'
compile 'org.springframework:spring-context:4.1.1.RELEASE'
compile 'org.springframework:spring-webmvc:4.1.1.RELEASE'

def tomcatVersion = '7.0.11'
tomcat "org.apache.tomcat.embed:tomcat-embed-core:${tomcatVersion}"
tomcat "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'
}
}

tomcat {
httpPort = 8080
httpsPort = 8081
}

关于tomcat - gradle-tomcat-plugin `Could not create task of type ' TomcatRun'`,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27055315/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com