2014-10-08 306 views
1

我正在開發使用MongoDB的Spring Web服務,我正在用Gradle構建它。我想在Heroku上部署它。我按照文檔做俯臥撐,我改變了buildpack的gradle上,根據本: https://devcenter.heroku.com/articles/buildpacks在Heroku上部署Spring應用程序

在開始的時候,我做git init,那麼我將使用一切git add .使用git commit -m "message" commiting它。在標準程序之後,我正在使用git push heroku master將所有內容推送到heroku。

之後,依賴被下載,之後我收到提示:

1 error 
:compileJava FAILED 
FAILURE: Build failed with an exception. 
* What went wrong: 
Execution failed for task ':compileJava' 
> Compilation failed; see the compiler error output for details. 

... 

BUILD FAILED 

這裏是我的build.gradle:

buildscript { 
    repositories { 
     maven { url "http://repo.spring.io/libs-release" } 
     mavenLocal() 
     mavenCentral() 
    } 
    dependencies { 
     classpath("org.springframework.boot:spring-boot-gradle-plugin:1.1.7.RELEASE") 
    } 
} 

apply plugin: 'java' 
apply plugin: 'application' 
apply plugin: 'eclipse' 
apply plugin: 'idea' 
apply plugin: 'spring-boot' 

jar { 
    baseName = 'appname' 
    version = '0.1.0' 
} 

repositories { 
    mavenLocal() 
    mavenCentral() 
    maven { url "http://repo.spring.io/libs-release" } 
} 

dependencies { 
    compile("org.springframework.boot:spring-boot-starter-web") 

    compile("org.springframework.boot:spring-boot-starter-actuator") 
    testCompile("junit:junit") 

    compile("org.springframework.data:spring-data-rest-webmvc") 
    compile("org.springframework.data:spring-data-mongodb") 

    compile("com.google.guava:guava:17.0") 
    compile("org.apache.commons:commons-lang3:3.3.2") 
} 

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

task stage(dependsOn: ['clean', 'installApp']) 

任何人有解決方案嗎?提前致謝。

+1

您的應用程序根本無法編譯。這可能是由於許多原因。嘗試使用'gradlew compileJava'在本地運行您的Gradle構建。你應該得到一個更有用的信息。 – 2014-10-09 03:28:49

+0

應用程序在本地使用'gradle compileJava'正確運行。 'gradlew'在我的cmd上不起作用。 – Forin 2014-10-09 08:50:05

+0

可能會嘗試從您的存儲列表中刪除本地的maven。這在遠程構建時可能會導致問題。 – 2014-10-09 23:25:47

回答

0

也許是向您展示最佳文件集的最佳方式,您可以比較我們的不同之處。最值得一提的是,你甚至沒有編譯與Heroku的編譯無關的內容。

鏈接到Github項目,如果有人需要它! https://github.com/arose13/Heroku-Spring-Gradle_Example

的Procfile

web: java $JAVA_OPTS -Dserver.port=$PORT -jar app.jar 

一個例子搖籃文件

group 'com.springtest.api' 
version '1.0-SNAPSHOT' 

buildscript { 
    repositories { 
     mavenCentral() 
    } 
    dependencies { 
     classpath("org.springframework.boot:spring-boot-gradle-plugin:1.2.5.RELEASE") 
    } 
} 

apply plugin: 'java' 
apply plugin: 'eclipse' 
apply plugin: 'idea' 
apply plugin: 'spring-boot' 

mainClassName = "hello.Application" 

jar { 
    baseName = 'spring-test-api' 
    version = '0.1.0' 
} 

repositories { 
    mavenCentral() 
} 

sourceCompatibility = 1.8 

dependencies { 
    testCompile 'junit:junit:4.11' 

    // Spring Framework 
    compile 'org.springframework.boot:spring-boot-starter-web' 

} 

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

task stage(type: Copy, dependsOn: [clean, build]) { 
    from jar.archivePath 
    into project.rootDir 
    rename { 
     'app.jar' 
    } 
} 
stage.mustRunAfter(clean) 

clean << { 
    project.file('app.jar').delete() 
}