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. C陷阱和缺陷学习笔记

    这段时间把<C陷阱和缺陷>看了,没时间自己写总结.就转一下别人的学习笔记吧http://bbs.chinaunix.net/thread-749888-1-1.html Chapter 1 ...

  2. Spark 基本概念

    Application:用户编写的 Spark 应用程序,包含驱动程序(Driver),和分布在集群中多个节点上运行的 Executor 代码,在执行过程中由一个或多个作业组成 Driver(驱动程序 ...

  3. 浅试 Webview 一app 加载 H5小游戏

    整体架构: InventionActivity:实现UI的实例化,基本的按钮Activity之间跳转 GameActivity:实现UI的实例化,Webview的基本使用 MyProgressDial ...

  4. require.js实现js模块化编程(一)

    1.认识require.js: 官方文档:http://requirejs.org/RequireJS是一个非常小巧的JavaScript模块载入框架,是AMD规范最好的实现者之一.最新版本的Requ ...

  5. python参考手册一书笔记之第一篇上

    在python2和python3的版本差异很大输出hello world的方法在2里支持在3里就不支持了. print 'hello world' #在2中支持 print ('hello world ...

  6. Java基础笔记3

    控制语句 1. if语句 if(条件){ //如果条件成立,则运行该大括号内的内容. } if(条件){ //如果条件成立,则运行该大括号内的内容. }else{ //如果条件不成立,则运行该大括号内 ...

  7. 数据分析与展示——NumPy库入门

    这是我学习北京理工大学嵩天老师的<Python数据分析与展示>课程的笔记.嵩老师的课程重点突出.层次分明,在这里特别感谢嵩老师的精彩讲解. NumPy库入门 数据的维度 维度是一组数据的组 ...

  8. Leetcode题解(十八)

    51.N-Queens ---------------------------------------------------------------------------------分割线---- ...

  9. IdentityServer4 登录成功后,跳转到原来页面

    IdentityServer4 登录成功后,默认会跳转到Config.Client配置的RedirectUris地址http://localhost:5003/callback.html,用于获取 T ...

  10. Android 开发笔记___复选框__checkbox

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout ...