zoukankan      html  css  js  c++  java
  • Springboot helloworld入门最经典例子

    一、建立maven java项目

     导入springboot包

    二、配置pom.xml

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
      <modelVersion>4.0.0</modelVersion>
    
      <groupId>com.ij34.example</groupId>
      <artifactId>Bootproject</artifactId>
      <version>0.0.1-SNAPSHOT</version>
      <packaging>jar</packaging>
    
      <name>Bootproject</name>
      <url>http://maven.apache.org</url>
    
      <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
      </properties>
    
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.6.RELEASE</version>
    </parent>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
    </dependencies>
    </project>

    三、代码测试

    package hello;
    
    import java.util.Date;
    
    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.ResponseBody;
    
    /** 
    * @author Admin
    * @date 创建时间:2017年8月28日 下午4:14:54 
    * @version 1.0
    *@type_name SampleController
    */
    @Controller
    @EnableAutoConfiguration
    public class SampleController {
        
        @RequestMapping("/")
        @ResponseBody
        String home(){
            return "Hello World:"+new Date();
        }
        public static void main(String[] args) {
            // TODO Auto-generated method stub
           SpringApplication.run(SampleController.class, args);
        }
    
    }

    附加:spring-boot-cli下载地址

    http://repo.spring.io/release/org/springframework/boot/spring-boot-cli/

  • 相关阅读:
    ES6常用新特性
    jquery基础总结 -- 转载
    正则验证
    prop attr 到底哪里不一样?
    分页导航 获取当前页码 的 分页导航哦
    使用Bootatrap的心得
    使用padding来合理布局自己的容器类
    使用angular-ui-router替代ng-router
    使用jitpack来获取github上的开源项目
    关于移动端的UI事件分类
  • 原文地址:https://www.cnblogs.com/tk55/p/7444678.html
Copyright © 2011-2022 走看看