1使用idea创建springboot项目如下图所示 并选择web模块

2,登录springboot官网 http://projects.spring.io/spring-boot/ 引入相关依赖包如图所示我们这里是基于1.5.8

3.引入springboot核心包,开始我们的helloworld之旅,pom文件如图所示

<?xml version="1.0" encoding="UTF-8"?>
<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.</modelVersion> <groupId>cm.test.cn</groupId>
<artifactId>springboot-test</artifactId>
<version>0.0.-SNAPSHOT</version>
<packaging>jar</packaging> <name>springboot-test</name>
<description>Demo project for Spring Boot</description> <parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5..RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent> <properties>
<project.build.sourceEncoding>UTF-</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties> <dependencies>
<!--引入springboot-starter核心Spring Boot starter,包括自动配置支持,日志和YAML-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency> <!--对web应用支持-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!--测试使用-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies> <!--maven插件-->
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build> </project>

4、编写启动类(注意启动类一般放在包的最外包)因为启动类只会扫描本报子包,同级包中的信息不然会报错

package cm.test.cn;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication
public class SpringbootTestApplication { public static void main(String[] args) { SpringApplication.run(SpringbootTestApplication.class, args);
}
}

5、编写controller

package cm.test.cn.controller;

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;
import org.springframework.web.bind.annotation.RestController; @RestController
@EnableAutoConfiguration
public class SampleController {
@RequestMapping("/hello")
public String home() { return "Hello World!";
} }

此时我们启动,这个启动类并在浏览器窗口访问如下图所示一个简单的hello,world就完成了,很简单吧!

项目已上传码云:https://gitee.com/wuhongpu/springboot-test.git

springboot-helloworld的更多相关文章

  1. spring boot 初试,springboot入门,springboot helloworld例子

    因为项目中使用了spring boot ,之前没接触过,所以写个helloworld玩玩看,当做springboot的一个入门例子.搜索 spring boot.得到官方地址:http://proje ...

  2. SpringBoot——HelloWorld

    微服务和单体应用的宏观理解 微服务:一组小型应用通过HTTP的方式进行沟通的开发思想 单体应用:ALL IN ONE 单体应用的不足: 随着业务逻辑的不断更新和迭代开发,起初的小型应用会不断膨胀,当应 ...

  3. Springboot helloworld入门最经典例子

    一.建立maven java项目 导入springboot包 二.配置pom.xml <project xmlns="http://maven.apache.org/POM/4.0.0 ...

  4. 2.SpringBoot HelloWorld详解

    1.POM文件 父项目 <parent> <groupId>org.springframework.boot</groupId> <artifactId> ...

  5. 五、SpringBoot—HelloWorld案例

    弱弱的补充一下啊,,,上一讲如果个别同学创建完项目之后发现项目pom.xml文件或者项目其他地方报错,你可以安装下图操作: HelloWorld案例: 编写好之后启动项目(贼姬霸简单) 启动成功: 浏 ...

  6. SpringBoot — HelloWorld开发部署

    springboot官方推荐使用jdk1.8 一.配置pom.xml 二.Application.java 三.HelloController.java 四.项目运行: Application.jav ...

  7. SpringBoot学习之Helloworld

    1. 如果使用Spring开发一个"HelloWorld"的web应用 创建一个web项目并且导入相关jar包.SpringMVC Servlet 创建一个web.xml 编写一个 ...

  8. SpringBoot的 HelloWorld

    SpringBoot HelloWorld 功能需求 ​ 浏览器发送hello请求,服务器接收请求并处理,相应HelloWorld字符串 1.创建一个maven工程:(jar) 2.导入SpringB ...

  9. SpringData 基于SpringBoot快速入门

    SpringData 基于SpringBoot快速入门 本章通过学习SpringData 和SpringBoot 相关知识将面向服务架构(SOA)的单点登录系统(SSO)需要的代码实现.这样可以从实战 ...

  10. springboot-01 helloworld

    第一个springboot程序 新建maven项目,添加如下依赖: <?xml version="1.0" encoding="UTF-8"?> & ...

随机推荐

  1. Call From master/192.168.128.135 to master:8485 failed on connection exception: java.net.ConnectException: Connection refused

    hadoop集群搭建了ha,初次启动正常,最近几天启动时偶尔发现,namenode1节点启动后一段时间(大约10几秒-半分钟左右),namenode1上namenode进程停掉,查看日志: -- :: ...

  2. 基于netfilter和LVM的密码窃取

    一:要求: 编写一个基于netfilter的模块,该模块的功能是捕获如mail.ustc.edu.cn等使用明文传输用户名和密码的网站的用户名和密码:并在接收到特定的ICMP数据包之后将捕获的用户名和 ...

  3. Leetcode题解(二)

    4.Median of Two Sorted Arrays(*) 题目 题目要求找到两个排序数组的中位数. 中位数的定义:当n为奇数时,median = array[n/2];当n为偶数时,media ...

  4. Problem A

    Problem Description Given a sequence a[1],a[2],a[3]......a[n], your job is to calculate the max sum ...

  5. Knight Moves

    Problem Description A friend of you is doing research on the Traveling Knight Problem (TKP) where yo ...

  6. jquerymobile实例介绍

    [创建页面]   data-role="page" 是在浏览器中显示的页面..   data-theme="b"更换主题,有a和b两种   data-role= ...

  7. awk巩固练习题

    第1章 awk数组练习题 1.1 文件内容(仅第一行) [root@znix test]# head -1 secure-20161219 access.log ==> secure-20161 ...

  8. zookeeper分布式搭建

    1下载并解压zookeeper安装包 2进入zookeeper配置文件目录,找到zoo_sample.cfg,执行cp zoo_sample.cfg  zoo.cfg 3打开zoo.cfg文件,修改d ...

  9. Python入门学习(一)

    看完了莫烦Python的视频,对于Python有了一点感觉,接下来打算把小甲鱼的视频啃完,附上学习网址:http://blog.fishc.com/category/python 小甲鱼的视频是从零基 ...

  10. URLs对象 blob URL

    把指向数据的URL保存到file或者blob对象里,好处就是不需要先文件读取内容然后才能用.   function createObjectURL(blob){if (window.URL){retu ...