zoukankan      html  css  js  c++  java
  • 2springboot:快速创建springboot项目

     使用IDEA快速创建springboot项目流程:

     创建新的项目选择

     项目的命名以及包名

     

     需要什么包就导入什么包

     

     进行测试的单元

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>

    此时的工程默认有这个启动的主程序

    Springboot01Application.java
    @SpringBootApplication
    public class Springboot01Application {
        public static void main(String[] args) {
            SpringApplication.run(Springboot01Application.class, args);
        }
    }

     新建一个controller包和controller类:

    //此时类的所有方法都会返回数据给浏览器(对象是专为json)
    //@RestController  = @ResponseBody + @Controller
    @ResponseBody
    @Controller
    public class Helloword {
        @RequestMapping("/hello")
        public  String hello(){
    
            return "Hello tow!";
        }
    }

     运行访问:

     

     springboot工程结构:

     

    static文件夹:保存所有的静态资源
    templates文件夹:保存所有的模板页面(Springboot默认jar使用嵌入式的Tomcat,默认不支持jsp页面);可以使用模板引擎
    application.properties:springboot应用的配置文件
  • 相关阅读:
    java 代码规范 sun 公司
    软引用、弱引用、虚引用
    socket
    httpURLConnection、URL、httpClient、httpPost、httpGet
    android service aidl 理解
    Python2.7-codecs
    Python2.7-textwrap
    Python2.7-StringIO和cStringIO
    Python2.7-difflib
    Python2.7-struct模块
  • 原文地址:https://www.cnblogs.com/Mrchengs/p/10115166.html
Copyright © 2011-2022 走看看