Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SpringBoot 3.0.3 can't identify any @RestController anotated class except in Startup Class #34382

Closed
r-asou opened this issue Feb 25, 2023 · 6 comments
Labels
status: duplicate A duplicate of another issue

Comments

@r-asou
Copy link

r-asou commented Feb 25, 2023

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

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Feb 25, 2023
@bclozel
Copy link
Member

bclozel commented Feb 25, 2023

Closing as a duplicate of #34379

@bclozel bclozel closed this as not planned Won't fix, can't repro, duplicate, stale Feb 25, 2023
@bclozel bclozel added status: duplicate A duplicate of another issue and removed status: waiting-for-triage An issue we've not yet triaged labels Feb 25, 2023
@kamrankamilli
Copy link

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.

@softboy99
Copy link

spring boot 3.0.4 still has this problem

@wilkinsona
Copy link
Member

wilkinsona commented Mar 8, 2023

@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.

@softboy99
Copy link

Spring Boot 3.0.4 shiped with Spring Framework 6.0.6, on the spring official website, it's said

@wilkinsona
Copy link
Member

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: duplicate A duplicate of another issue
Projects
None yet
Development

No branches or pull requests

6 participants