0
votes

I have problem with setting up HEAD resposnse from RestController in Spring Boor. I'm currently using Spring Boot version 1.5.9.

I have settup new project for demostrating this problem. In application.properties I have just one line:

server.context-path=/api/v1

My RestController "TestController.java"

@RestController
public class TestController {

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

When I try to get only header with HTTP HEAD request on url http://localhost:8080/api/v1/test, then the response stack and I don't get any response. In app console there is no errors.

If I remove server.context-path=/api/v1 from application.properties. Then HEAD request to http://localhost:8080/test is working as expected.

Thank you for any help, Martin

1
Nothing seems wrong here. can you share your pom file? - Pravin K
I overlook your reaction. I'm using gradle. - Martin Spudich

1 Answers

0
votes

Here is the 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')
}