Spring Boot 1.5.9上下文路径HEAD响应不起作用

时间:2018-01-25 08:00:17

标签: spring-boot head contextpath

我在Spring Boor中从RestController设置HEAD resposnse时遇到问题。我目前正在使用Spring Boot 1.5.9版。

我已经解决了这个问题的新项目。在application.properties中,我只有一行:

server.context-path=/api/v1

我的RestController“TestController.java”

@RestController
public class TestController {

    @GetMapping("/test")
    public String test() {
        return "test";
    }
}

当我尝试在url http://localhost:8080/api/v1/test上只获取带有HTTP HEAD请求的标头时,那么响应堆栈并没有得到任何响应。在app控制台中没有错误。

如果我从application.properties中删除server.context-path = / api / v1。然后HEAD对http://localhost:8080/test的请求正在按预期工作。

感谢您的帮助, 马丁

1 个答案:

答案 0 :(得分:0)

这是build.gradle

buildscript {
    ext {
        springBootVersion = '1.5.9.RELEASE'
    }
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
    }
}

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'

group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8

repositories {
    mavenCentral()
}


dependencies {
    compile('org.springframework.boot:spring-boot-starter-web')
    compile('org.springframework.boot:spring-boot-starter-websocket')
//    compile('com.microsoft.sqlserver:sqljdbc4')
    runtime('org.springframework.boot:spring-boot-devtools')
    testCompile('org.springframework.boot:spring-boot-starter-test')
}
相关问题