第一个springboot程序

新建maven项目,添加如下依赖:

<?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.0</modelVersion>
<!--项目信息-->
<groupId>com.mlxs.springboot.helloworld</groupId>
<artifactId>mlxs-springboot-helloworld</artifactId>
<version>1.0-SNAPSHOT</version> <!--父依赖包-->
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.2.RELEASE</version>
<relativePath/>
</parent> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
</properties> <dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency> <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency> <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency> </dependencies>
</project>

新建项目启动类:

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; /**
* MainApp类描述:
*
* @author yangzhenlong
* @since 2017/2/9
*/
@SpringBootApplication
public class MainApp {
public static void main(String[] args) {
SpringApplication.run(MainApp.class, args);
}
}

新建restful接口类:

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; /**
* HelloWorldController类描述:
*
* @author yangzhenlong
* @since 2017/2/9
*/
@RestController
public class HelloWorldController { @RequestMapping("/index")
public String index() {
return "Hello World";
}
}

然后启动MainApp,浏览器中访问:http://localhost:8080/index,得到响应:

第一个springboot HelloWorld程序就完成了。

springboot-01 helloworld的更多相关文章

  1. [.NET MVC4 入门系列01]Helloworld MVC 4 第一个MVC4程序

    [.NET MVC4 入门系列01]Helloworld MVC 4 第一个MVC4程序   一.练习项目: http://www.asp.net/mvc/tutorials/mvc-4/gettin ...

  2. springboot之HelloWorld

    简介 为了简化开发Spring的复杂度,Spring提供了SpringBoot可以快速开发一个应用,这里就简单介绍下SpringBoot如何快速开发一个J2EE应用 HelloWorld 首先在gra ...

  3. ExtJS实战 01——HelloWorld

    前言 Extjs5的发布已经有些日子了,目前的最新稳定版本是Extjs5.1.0,我们可以在官方网站进行下载.不过笔者今天访问得到的是502Bad Gateway,原因可能是sencha的nigix没 ...

  4. SpringBoot学习helloworld

    这几天开始学习springBoot记录一下(Hello World) pom.xml <project xmlns="http://maven.apache.org/POM/4.0.0 ...

  5. SpringBoot的HelloWorld 应用及解释

    参考链接: Spring Data JPA - Reference Documentation Spring Data JPA--参考文档 中文版 纯洁的微笑:http://www.ityouknow ...

  6. [一]SpringBoot 之 HelloWorld

    (1)新建一个Maven Java工程 (2)在pom.xml文件中添加Spring BootMaven依赖 2.1在pom.xml中引入spring-boot-start-parent spring ...

  7. SpringBoot入门学习(一): Idea 创建 SpringBoot 的 HelloWorld

    创建项目: 项目结构: 程序启动入口: 正式开始: package com.example.demo; import org.springframework.boot.SpringApplicatio ...

  8. redis整合springboot的helloworld

    引入依赖 compile 'org.springframework.boot:spring-boot-starter-data-redis' 使用redis有两种方法 1.Jedis Jedis je ...

  9. SpringBoot——探究HelloWorld【三】

    前言 前面我们写了helloworld的一个,这里我们对他进行分析 探究 那么下面就开始我们的探究之旅吧,首先从POM文件来,在POM文件中我们导入了项目所需要的依赖 POM文件 父项目 <pa ...

  10. spring-boot的helloWorld详解

    1.运行环境 开发工具:intellij idea JDK版本:1.8 项目管理工具:Maven 3.2.5 2.Maven Plugin管理 pom.xml配置代码: <project xml ...

随机推荐

  1. poj 3186 Treats for the Cows(dp)

    Description FJ has purchased N (1 <= N <= 2000) yummy treats for the cows who get money for gi ...

  2. cf 990G - GCD Counting

    题意 #include<bits/stdc++.h> #define t 200000 #define MAXN 200100 using namespace std; int n; in ...

  3. A1136. Delayed Palindrome

    Consider a positive integer N written in standard notation with k+1 digits a​i​​ as a​k​​⋯a​1​​a​0​​ ...

  4. FindExecutable:查找与一个指定文件关联在一起的程序的文件名

    百度百科:http://baike.baidu.com/view/1285880.htm ------------------------------------------------------- ...

  5. MySQL排序函数field()详解

    在日常开发过程中,排序是经常用到的,有时候有这样的需求. 比如,需要在查询结果中根据某个字段的具体值来排序.如下面例子 上面是一张个人信息 表,假如我们想按照'seiki','iris','xut'来 ...

  6. c#两个listbox怎么把内容添加到另外个listbox

    https://bbs.csdn.net/topics/392156324?page=1  public partial class Form1 : Form     {         public ...

  7. The CLI moved into a separate package: webpack-cli.解决办法

    The CLI moved into a separate package: webpack-cli.Please install ‘webpack-cli‘ in addition to webpa ...

  8. Tomcat 启动时 警告: [SetPropertiesRule]{Server/Service/Engine/Host/Context}

    在Eclipse 中,启动Tomcat 时,出现: 警告: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting proper ...

  9. Tree Restoration Gym - 101755F (并查集)

    There is a tree of n vertices. For each vertex a list of all its successors is known (not only direc ...

  10. Nginx+Keeplived双机热备(主从模式)

    Nginx+Keeplived双机热备(主从模式) 参考资料: http://www.cnblogs.com/kevingrace/p/6138185.html 双机高可用一般是通过虚拟IP(漂移IP ...