更新 最初在我的 gradle build 的 war 文件初始化时出现了 Tomcat 异常。在作者的一些帮助下,它现在正在部分部署和运行 albiet。这可能是由于 Gradle 中的一个错误。在下面的服务根目录中使用更新的 build.gradle 和 SpringData Rest 输出进行编辑。
我一直在尝试编译和运行一个最初用 Maven 编写的 Spring Data Rest 项目,而不是 Gradle。
教程位置: http ://www.javacodegeeks.com/2013/08/spring-data-rest-in-action.html
我的项目构建良好,通过以下方式进入战争
* build.gradle *
buildscript {
repositories {
maven { url "http://repo.spring.io/libs-milestone" }
mavenLocal()
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'war'
war {
baseName = 'whichdegree-service'
version = '0.1.0'
}
repositories {
mavenCentral()
maven { url "http://repo.spring.io/libs-milestone" }
maven { url "https://repository.jboss.org/nexus/content/repositories/releases" }
}
dependencies {
compile("org.springframework.boot:spring-boot-starter-web:0.5.0.M5")
compile("org.springframework:spring-orm:4.0.0.M3")
compile("org.springframework.data:spring-data-jpa:1.3.2.RELEASE")
compile("org.springframework.data:spring-data-commons-core:1.3.2.RELEASE")
compile("org.hibernate:hibernate-entitymanager:4.2.1.Final")
//Added by author of tutorial
compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.+'
compile group: 'ch.qos.logback', name: 'logback-classic', version: '1.+'
//Spring-Data-REST, upgraded to 2.0.0 and Tomcat served war properly
compile("org.springframework.data:spring-data-rest-webmvc:2.0.0.M1")
//HSQL DB
compile("org.hsqldb:hsqldb:1.8.0.10")
testCompile("junit:junit:4.11")
}
task wrapper(type: Wrapper) {
gradleVersion = '1.8'
}
task copyDependencies(type: Copy) {
description = 'Copy dependencies to libs. Useful for Eclipse'
libDir = new File(project.projectDir, '/libs')
println libDir
println 'Adding dependencies from compile configuration'
for(file in configurations.compile) {
println 'Added ' + file
copy
{
from file
into libDir
}
}
}
切换到 Spring Data REST 固定部署的 2.0 版本,但是该服务似乎没有激活或工作:
GET 在 service_root/ 的预期结果
{
"links" : [ {
"rel" : "books",
"href" : "http://localhost:8080/books"
}, {
"rel" : "authors",
"href" : "http://localhost:8080/authors"
} ],
"content" : [ ]
}
为我服务的 GET 实际结果
{
"links" : [ ],
"content" : [ ]
}
想知道这是否可能是 Gradle 本身的错误,没有正确连接 Spring-Data-Rest..?