zoukankan      html  css  js  c++  java
  • spring boot 的使用

    一:首先安装spring boot插件

    两种方式安装,

    1:使用myeclipse自带的安装插件的功能

    help>  install from catalog> 将出现下面的界面,搜寻spring boot  点击install安装

    2:使用maven工程,在pom.xml中添加spring boot依赖,将会添加spring boot插件

        

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

    二:在resource下面建立static,templates,application.properites文件夹。工程中的静态文件放在static文件夹下,工程开启后将会直接映射到static文件夹。可以直接访问下面的文件

      三:创建工程入口:在main所属的类上使用@SpringBootApplication注解,说明这是一个spring boot 工程

    四:创建一个controller

    @Controller
    public class DemoController {
    
        @ResponseBody
        @RequestMapping("/hello")
        public String helloWorld() {
            // TODO Auto-generated method stub
            return "Hello world";
    
        }

        @ResponseBody
        @RequestMapping(value="/pojo",method=RequestMethod.GET)
        public User showUser(@RequestParam("name") String name){  //@RequestParam接收从url传送过来的参数
            User u=new User();
            u.setId(3);
            u.setUsername(name);
            u.setAddress("武当山");
            u.setBirthday(new Date());
            u.setSex("male");
            return u;
        }
    
    }

    五:启动spring boot 工程,使用浏览器访问,成功。

    六:整合mybatis,在mybatis中添加配置文件,spring boot将会自动扫描,加载配置

         

     

          七:添加依赖插件,从Maven reporsities寻找要添加的插件,添加

      

       

        

    本博客为非营利性个人原创,除部分有明确署名的作品外,所刊登的所有作品的著作权均为本人所拥有,本人保留所有法定权利。违者必究
  • 相关阅读:
    魔兽世界中的一些公式
    T端大灾变版本传送大师(NPC 脚本)
    T端带数据库查询的假人系统
    T端GM上线提示
    T端mysql优化设置
    T端根据玩家职业来显示不同颜色的角色名字的C++代码
    IOS复习-UIButton
    从明天开始认真写博客
    为什么到今天还要坚持写博客
    cocos2d—1—环境安装
  • 原文地址:https://www.cnblogs.com/liyafei/p/7892445.html
Copyright © 2011-2022 走看看