创建新的springboot项目,编写测试test方法,然后启动工程。
此时启动项目正常,访问:127.0.0.1:8080/test
页面出现404
后台日志报
此问题是因为在springboot默认创建的启动类中无**@RestController**注解
package com.example.demo;
import java.util.HashMap;
import java.util.Map;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
@RestController
@SpringBootApplication
public class Demo3Application {
public static