我正在使用MongoDB开发Spring Web服务,我正在用gradle构建它。我想在Heroku上部署它。我正在根据文档进行推送,并且我在gradle上更改了buildpack,根据这个: https://devcenter.heroku.com/articles/buildpacks
一开始,我正在git init
,然后我使用git add .
添加所有内容并使用git commit -m "message"
提交。在那个标准程序之后,我使用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'])
任何人都有解决方案吗?提前谢谢。
答案 0 :(得分:0)
也许是向您展示最佳文件集的最佳方式,您可以比较我们的不同之处。最值得一提的是你甚至没有编译哪些可能与Heroku的编译无关。
如果有人需要,可以链接到Github项目! https://github.com/arose13/Heroku-Spring-Gradle_Example
Procfile
web: java $JAVA_OPTS -Dserver.port=$PORT -jar app.jar
示例Gradle文件
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()
}