码迷,mamicode.com
首页 > 编程语言 > 详细

spring_boot攻略1.1-hello SpringBoot

时间:2017-04-17 12:30:59      阅读:214      评论:0      收藏:0      [点我收藏+]

标签:tar   rom   ati   res   frame   auto   输入   model   gap   

交流账号:2318645572

说明:

开发工具:eclipse

开发系统:windows 7

开发规范:maven项目

注意:按照我说的方式做下去

1.导包: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>cn.tedu</groupId>
  <artifactId>springboot2</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>war</packaging>
  <name> springboot2</name>  
  <parent>    
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-parent</artifactId>
  <version>1.3.3.RELEASE</version><!-- lookup parent from repository -->
  </parent>
  
      <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-web</artifactId>
  <version>1.3.3.RELEASE</version>
  <classifier>sources</classifier>
</dependency>
    </dependencies>
  
</project>

 

2.创建application.java

技术分享

 

 

package controller;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

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

 3.创建HelloSpringBoot.java

 

技术分享

package controller;

import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

@RestController
public class HelloSpringBoot {
    @RequestMapping(value = "/")
    String index(){
        return "Hello Spring Boot!";
    }
    @RequestMapping(value="/back")
    String demo1(){
        return "jjjjj";
    }
}                                                                              
    

4.启动Application.java

可以在debug中右键启动

技术分享

5,验收

打开浏览器,输入http://localhost:8080/

技术分享

 

spring_boot攻略1.1-hello SpringBoot

标签:tar   rom   ati   res   frame   auto   输入   model   gap   

原文地址:http://www.cnblogs.com/wx-ym-good/p/6707247.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!