SpringBoot version: 3.0.3
OS: Windows 11
Java: OpenJDK 19
Recently I just wrote a simple Spring Boot application.
And I used the latest Spring Boot and the version is 3.0.3.
What I did is I wrote a simple controller, but I found Spring boot can't identify this. But if I put the simple mapping in startup class, it can work.
The code is simple as below:
package com.example.controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class StorageController {
@GetMapping("/hello/hello")
public String hello() {
return "hello";
}
}
The startup class:
package com.example;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@SpringBootApplication
@RestController
public class StorageApplication {
public static void main(String[] args) {
SpringApplication.run(StorageApplication.class, args);
}
@GetMapping("hello")
public String hello() {
return "hello";
}
}
Base on my setting, it should have 2 mapping which is /hello and/hello/hello.
Actually, it only can find the first one written in startup class
But it's work in Spring boot 2.7.9
Comment From: bclozel
Closing as a duplicate of #34379
Comment From: kamrankamilli
I have the same issue with spring boot 3.0.3 using Ubuntu, I'm not sure if it is specific to Windows. Previously I was using Spring Boot 3.0.2 and had no problems.
Comment From: softboy99
spring boot 3.0.4 still has this problem
Comment From: wilkinsona
@softboy99 Please ensure that you're using Spring Framework 6.0.6 as that's where the fix was made. If you still have a problem when using Spring Framework 6.0.6 please open a Spring Framework issue and provide a minimal sample that reproduces the problem.
Comment From: softboy99
Spring Boot 3.0.4 shiped with Spring Framework 6.0.6, on the spring official website, it's said
Comment From: wilkinsona
@softboy99 Yes, that's correct, but we have no way of knowing if that's the version that your application is actually using. Something may have overridden Spring Boot's dependency management. As I said above, if you can reproduce the problem with Spring Boot 3.0.4 and Spring Framework 6.0.6, please open a Spring Framework issue and provide a minimal sample.