hello springboot

hello springboot

  1. 通过网页创建新springboot的项目:https://start.spring.io/

  2. 也可以通过idea直接创建

  3. 直接新建一个controller

    @Controller
    public class HelloController {
    
        @RequestMapping("/hello")
        @ResponseBody//返回字符串
        public String hello(){
            return "hello world";
        }
    }
    
  4. 访问测试http://localhost:8080/hello

  5. 可以通过application.properties更改默认端口号

    server.port=8081
    
  6. 在resources下新建banner.txt可以自定义启动的banner,https://www.bootschool.net/ascii

                      _                 _
            _        ( )               ( )
     _ _   (_)  ___  | |/')    __     _| |
    ( '_` | |/' _ `| , <   /'__` /'_` |
    | (_) )| || ( ) || |\` (  ___/( (_| |
    | ,__/'(_)(_) (_)(_) (_)`\____)`\__,_)
    | |
    (_)
    
原文地址:https://www.cnblogs.com/pinked/p/12332192.html