首页 > 解决方案 > GET /me 没有映射

问题描述

我有这个弹簧靴应用程序,我是弹簧靴的新手。我创建了这个控制器,但它抛出 404 并在控制台中显示 No mapping for GET /me。我找不到问题,我需要尽快解决。

这是日志:https ://pastebin.com/Qf5W6MZU

此控制器中的任何其他端点也不起作用。

import org.sefglobal.scholarx.exception.BadRequestException;
import org.sefglobal.scholarx.exception.NoContentException;
import org.sefglobal.scholarx.exception.ResourceNotFoundException;
import org.sefglobal.scholarx.exception.UnauthorizedException;
import org.sefglobal.scholarx.model.Mentee;
import org.sefglobal.scholarx.model.Profile;
import org.sefglobal.scholarx.model.Program;
import org.sefglobal.scholarx.service.IntrospectionService;
import org.sefglobal.scholarx.util.EnrolmentState;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.CookieValue;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/me")
public class AuthUserController {

    private final IntrospectionService introspectionService;

    public AuthUserController(IntrospectionService introspectionService) {
        this.introspectionService = introspectionService;
    }

    @GetMapping
    @ResponseStatus(HttpStatus.OK)
    public Profile getLoggedInUser(@CookieValue(value = "profileId", defaultValue = "-1") long profileId)
            throws ResourceNotFoundException, UnauthorizedException {
        return introspectionService.getLoggedInUser(profileId);
    }

    @GetMapping("/programs/mentee")
    @ResponseStatus(HttpStatus.OK)
    public List<Program> getMenteeingPrograms(@CookieValue(value = "profileId") long profileId)
            throws ResourceNotFoundException, NoContentException {
        return introspectionService.getMenteeingPrograms(profileId);
    }

    @PutMapping("/mentor/{id}/confirmation")
    @ResponseStatus(HttpStatus.OK)
    public Mentee confirmMentor(@PathVariable long id,
                                @CookieValue(value = "profileId") long profileId)
            throws ResourceNotFoundException, BadRequestException {
        return introspectionService.confirmMentor(id, profileId);
    }
}

标签: javaspringspring-boot

解决方案


我发现了我没有包含软件包的问题。


推荐阅读