zoukankan      html  css  js  c++  java
  • SpringBoot初体验

    Springboot的一个HelloWorld

    工具:idea、java8

    一步步来~

    启动类:

    package com.aijiajia.springboot;
    
    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.SpringBootApplication;
    import org.springframework.context.annotation.ComponentScan;
    import org.springframework.stereotype.Controller;
    @Controller
    @SpringBootApplication
    @ComponentScan(basePackages = "com.aijiajia.*")
    public class SpringbootDemoApplication {
    
        public static void main(String[] args) {
            SpringApplication.run(SpringbootDemoApplication.class, args);
            System.out.println("SpringBoot启动成功啦");
        }
    }

    新建一个测试Controller:

    package com.aijiajia.controller;
    import org.springframework.stereotype.Controller;
    import org.springframework.web.bind.annotation.RequestMapping;
    import org.springframework.web.bind.annotation.ResponseBody;
    
    @Controller
    public class TestController {
    
        @RequestMapping("/test")
        @ResponseBody
        public String Test(){
            return "访问成功";
        }
    }

    接着启动启动类

    打开浏览器 访问:http://localhost:8080/test  

    OK  拜拜~

  • 相关阅读:
    flex>导航
    flex>图表控件
    Struts2>Cannot find the tag library descriptor for /strutstags
    jsp>Smartupload例子代码
    flex>MXML语法
    解决JBoss只能通过localhost(127.0.0.1)而不能通过IP访问
    jsp>tomcat配置虚拟目录
    JSF>概述
    Struts2>中文乱码
    flex>HttpService
  • 原文地址:https://www.cnblogs.com/aijiajia1314/p/9861332.html
Copyright © 2011-2022 走看看