首页 > 解决方案 > spring cloud项目前端显示404

问题描述

在做毕业设计的时候,尝试过使用spring cloud搭建框架。在搭建的过程中,由于自学的限制,有些知识点没有完全理解,所以遇到了很多问题。这些问题大部分都是通过网上前辈的分享解决的,但是现在遇到这个问题,在网上搜索了很多相关资料都没有找到解决办法。所以我在寻求帮助。

项目启动后,在rundashboard中点击端口号40999和40888时,谷歌浏览器显示404,如下: enter image description here 但是当我从Eureka页面访问时,它可以工作而且当我使用谷歌或者邮递员,页面仍然显示404和上面的错误信息。

在网上发现了很多相关的问题,包括应用。属性配置和启动类位置。仍然希望有人可以帮助我。谢谢。这是我的测试控制器。

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("/test")
@RestController
public class TestController {

    @RequestMapping("/hello")
    @ResponseBody
    public String test(){
        return "hello";
    }
}

这是 application.properties:

spring.application.name=client
server.port=40999
eureka.client.serviceUrl.defaultZone=http://localhost:20000/eureka/

这是控制台日志的图片。

标签: spring-bootspring-cloud

解决方案


推荐阅读