所以每当我尝试gradle startMongoDB
时,我都会收到此错误:
gradle startMongoDB
FAILURE: Build failed with an exception.
* Where:
Build file '/home/kaspar/Eclipse/workspace/conference-application/app/build.gradle' line: 2
* What went wrong:
A problem occurred evaluating project ':app'.
> Could not find method create() for arguments [tomcatRun, class org.gradle.api.plugins.tomcat.tasks.TomcatRun, org.gradle.api.plugins.tomcat.TomcatPlugin$_configureTomcatRun_closure2@1315391f] on task set.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 5.765 secs
当我尝试在Linux机器上运行它时,似乎只会发生这种情况。在Windows上,它运作良好。可能是什么问题?
请告诉我是否需要更多关于错误的信息,我会提供。
的build.gradle:
import org.apache.tools.ant.taskdefs.condition.Os
apply plugin: 'java'
repositories {
mavenCentral()
}
task wrapper(type: Wrapper, description: 'Gradle wrapper') {
gradleVersion = '1.11'
def jvmOpts = "-Xmx512m"
inputs.property("jvmOpts", jvmOpts)
doLast {
def optsEnvVar = "DEFAULT_JVM_OPTS"
scriptFile.write scriptFile.text.replace("$optsEnvVar=\"\"", "$optsEnvVar=\"$jvmOpts\"")
batchScript.write batchScript.text.replace("set $optsEnvVar=", "set $optsEnvVar=$jvmOpts")
}
}
task downloadMongoDB(description: 'Download and unpack MongoDB database') {
ext.mongoDBDir = new File('mongoDB')
if (!mongoDBDir.isDirectory()) {
ant.mkdir(dir: './mongoDB')
ant.mkdir(dir: './.tmp')
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
ant.with{
get src: 'http://fastdl.mongodb.org/win32/mongodb-win32-i386-2.4.10-rc0.zip', dest: './.tmp/mongoDB.zip', skipexisting: true
unzip src: './.tmp/mongoDB.zip', dest: './', overwrite: true
copydir src: './mongodb-win32-i386-2.4.10-rc0/', dest: './mongoDB/'
delete dir: './mongodb-win32-i386-2.4.10-rc0', deleteonexit: true
}
} else if (Os.isFamily(Os.FAMILY_MAC)) {
ant.with{
get src: 'http://fastdl.mongodb.org/osx/mongodb-osx-x86_64-2.4.10-rc0.tgz', dest: '.tmp/mongoDB.tgz', skipexisting: true
untar src: '.tmp/mongoDB.tgz', dest: './', overwrite: true, compression: 'gzip'
copydir src: './mongodb-osx-x86_64-2.4.10-rc0/', dest: './mongoDB/'
delete dir: './mongodb-osx-x86_64-2.4.10-rc0', deleteonexit: true
}
} else if (Os.isFamily(Os.FAMILY_UNIX)) {
// Needs testing
ant.with{
get src: 'http://fastdl.mongodb.org/linux/mongodb-linux-i686-2.4.10-rc0.tgz', dest: '.tmp/mongoDB.tgz', skipexisting: true
untar src: '.tmp/mongoDB.tgz', dest: './', overwrite: true, compression: 'gzip'
copydir src: './mongodb-linux-i686-2.4.10-rc0/', dest: './mongoDB/'
delete dir: './mongodb-linux-i686-2.4.10-rc0', deleteonexit: true
}
} else {
throw new StopExecutionException("Unknown operating system")
}
}
}
task repairMongoDB(type: Exec, dependsOn: 'downloadMongoDB', description: 'Repair MongoDB database') {
workingDir projectDir.path
ant.mkdir(dir: './data/db')
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
commandLine '.\\mongoDB\\bin\\mongod', '--dbpath', '.\\data\\db', '--logpath', '.\\data\\db\\mongodb.log', '--rest', '--logappend', '--repair'
}else{
// After unpack the files do not have executable permission
FileTree tree = fileTree('./mongoDB/bin').include('*');
tree.each { File file ->
file.setExecutable(true);
}
commandLine './mongoDB/bin/mongod', '--dbpath', './data/db', '--logpath', './data/db/mongodb.log', '--rest', '--logappend', '--repair'
}
}
task startMongoDB(type: Exec, dependsOn: 'repairMongoDB', description: 'Run MongoDB database') {
workingDir projectDir.path
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
commandLine '.\\mongoDB\\bin\\mongod','--port', '27017', '--dbpath', '.\\data\\db', '--logpath', '.\\data\\db\\mongodb.log', '--logappend', '--rest'
}else{
commandLine './mongoDB/bin/mongod', '--port', '27017', '--dbpath', './data/db', '--logpath', './data/db/mongodb.log', '--logappend', '--rest'
}
}
subprojects {
apply from: project.rootDir.path + "/gradle-include/eclipse.gradle"
if(project.file('src/main').exists()) {
apply from: project.rootDir.path + "/gradle-include/maven.gradle"
}
}
答案 0 :(得分:0)
通过安装最新的支架(1.11)
进行修复