想法调试或运行

时间:2017-08-10 11:33:39

标签: java debugging intellij-idea gradle

当我尝试从Idea I运行gradle项目时出现错误

  
    

失败:构建因异常而失败。

  
     
      
  • 出了什么问题:任务'运行应用程序'在根项目中找不到' app-search'。

  •   
  • 尝试:运行gradle任务以获取可用任务列表。使用--stacktrace选项运行以获取堆栈跟踪。使用--info或--debug选项运行以获取更多日志输出。创建图像构建失败

  •   
     

总时间:0.153秒任务'运行SearchApplication'在根中找不到   项目' app-search'。

请问如何解决。

1 个答案:

答案 0 :(得分:0)

这是build.gradle的主要部分

apply plugin: 'application'
    apply plugin: 'java'
    apply plugin: 'docker'
    apply plugin: 'com.github.johnrengelman.shadow'

    sourceCompatibility = 1.8

    ext {
        dropwizardVersion = '1.1.2'
        mainClass = "com.jobservice.search.AppLauncher"
        mapstructVersion = '1.1.0.Final'
    }
    mainClassName = mainClass

    repositories {
        mavenLocal()
        jcenter()
        mavenCentral()
    }


    buildscript {
        repositories { jcenter() }
        dependencies {
            classpath 'se.transmode.gradle:gradle-docker:1.2'
            classpath 'com.github.jengelman.gradle.plugins:shadow:1.2.4'
        }
    }


    // add logging into test stream
    test {
        testLogging.showStandardStreams = true
    }

    dependencies {

        compile group: 'org.bouncycastle', name: 'bcprov-jdk16', version: '1.46'
        compile group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.1'
        compile group: 'org.slf4j', name: 'slf4j-ext', version: '1.7.25'
        compile group: 'org.slf4j', name: 'slf4j-simple', version: '1.7.25'
        compile 'com.google.inject:guice:3.0'
        compile group: 'io.swagger', name: 'swagger-jersey2-jaxrs', version: '1.5.15'
        compile group: 'io.swagger', name: 'swagger-annotations', version: '1.5.15'
        compile group: 'com.hubspot.dropwizard', name: 'dropwizard-guice', version: '1.0.6.0'
        compile group: 'org.liquibase', name: 'liquibase-core', version: '3.5.3'

        compile (
                'io.dropwizard:dropwizard-core:' + dropwizardVersion,
                'io.dropwizard:dropwizard-hibernate:' + dropwizardVersion,
                'org.postgresql:postgresql:9.4.1208.jre7',
                'io.dropwizard:dropwizard-testing:' + dropwizardVersion
        )
        compile 'org.mapstruct:mapstruct-jdk8:' + mapstructVersion
        compile group: 'org.apache.commons', name: 'commons-collections4', version: '4.1'


        testCompile group: 'junit', name: 'junit', version: '4.12'
        testCompile group: 'org.hamcrest', name: 'hamcrest-junit', version: '2.0.0.0'
        testCompile 'org.mockito:mockito-core:2.0.54-beta'
        testCompile group: 'com.h2database', name: 'h2', version: '1.4.194'
        testCompile('org.glassfish.jersey.test-framework.providers:jersey-test-framework-provider-grizzly2:2.23.2') {
            exclude group: 'javax.servlet', module: 'javax.servlet-api'
            exclude group: 'junit', module: 'junit'
        }
    }

    // Configure the shadow jar task
    shadowJar {
        classifier = 'dist'
        baseName = 'jobs-search'
        version = "1.0"
        mergeServiceFiles()
        manifest {
            attributes 'Main-Class': mainClassName
        }
        version = ''
    }
    jar {
        manifest {
            attributes 'Main-Class': mainClassName
        }
    }