zoukankan      html  css  js  c++  java
  • spring boot初探

    又被领导鄙视了,说让先把程序跑起来,再去研究深层次的东西。。

    我又一次没有学会走就要开始跑了。。说干就干

    eclipse mars下载

    新建maven project

    加依赖

    <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
    <version>1.0.2.RELEASE</version>
    </dependency>

    等待maven帮忙下载jar包吧,太贴心!

    新建一个control类

    package com.mars.testweb.mavenTest;
    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
    import org.springframework.stereotype.Controller;
    import org.springframework.web.bind.annotation.RequestMapping;
    import org.springframework.web.bind.annotation.RequestMethod;
    import org.springframework.web.bind.annotation.ResponseBody;

    @Controller
    @EnableAutoConfiguration
    public class SimpleController {

    @RequestMapping(value ="/hello", method = RequestMethod.GET)
    @ResponseBody
    public String hello(){
    return "hello world";
    }
    public static void main(String[] args) {
    // TODO Auto-generated method stub
    SpringApplication.run(SimpleController.class, args);
    }

    }

    右键,run as java Application

    浏览器访问http://localhost:8080/hello

    出现helloWord了~

    spring boot真的就这么简单么,其实人家帮你屏蔽了很多细节,只需要关心业务逻辑实现,这固然是好的。

    but,要是这么3分钟就能build好环境,傻瓜不都能写代码了么?

    看看maven帮我们下载了哪些包呢?

    从下往上看,有spring的基本包,含MVC,还有tomcat的jar包,以后不用安装tomcat也能跑web应用(赞),以及spring-boot的包。

    虽然这么配置很简单,但是最好还是从头到尾配置一边,这样对spring框架才能有个全面的认识,当然,俺正在看spring的源码分析,稍后奉上,敬请期待。

  • 相关阅读:
    Workbooks 对象的 Open 方法参数说明
    OLDB读取excel的数据类型不匹配的解决方案
    使用OLEDB读取Excel
    C#锁定EXCEL工作表
    smple
    C# 获取当前文件、文件夹的路径及操作环境变量
    与eval()相关的技巧
    不写var的全局变量声明方式的一个副作用(Side Effects When Forgetting var)
    关于国内浏览器的userAgent识别
    for循环的效率改进写法二则
  • 原文地址:https://www.cnblogs.com/marszhw/p/5568744.html
Copyright © 2011-2022 走看看