声明:本文来源于MLDN培训视频的课堂笔记,写在这里只是为了方便查阅。

一、根据官网手工搭建(http://projects.spring.io/spring-boot/#quick-start)

1、新建一个maven工程springbootfirst

2、 如果要想开发 SpringBoot 程序只需要按照官方给出的要求配置一个父 pom (spring-boot-starter-parent)和添加web开发的支持(spring-boot-starter-web)即可。

 <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.study.springboot</groupId>
<artifactId>springbootfirst</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging> <name>springbootfirst</name>
<url>http://maven.apache.org</url> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jdk.version>1.8</jdk.version>
</properties> <!--想开发 SpringBoot 程序只需要按照官方给出的要求配置一个父 pom 即可。 -->
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.4.RELEASE</version>
</parent> <dependencies> <!--添加web开发的支持 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency> </dependencies> <build>
<finalName>springbootfirst</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${jdk.version}</source><!-- 源代码使用的开发版本 -->
<target>${jdk.version}</target><!-- 需要生成的目标class文件的编译版本 -->
<encode>${project.build.sourceEncoding}</encode>
</configuration>
</plugin>
</plugins>
</build> </project>

3、 编写一个具体的程序SampleController.java

 package com.study.springboot.springbootfirst;

 import org.springframework.boot.*;
import org.springframework.boot.autoconfigure.*;
import org.springframework.stereotype.*;
import org.springframework.web.bind.annotation.*; @Controller
@EnableAutoConfiguration
public class SampleController { @RequestMapping("/")
@ResponseBody
String home() {
return "Hello World!";
} public static void main(String[] args) throws Exception {
SpringApplication.run(SampleController.class, args);
}
}

4.启动SampleController.java,在浏览器输入http://localhost:8080/即可看到我们使用SpringBoot搭建的第一个web程序成功了,就是这么的快速、简单、方便

二、快速搭建

1、访问http://start.spring.io/

2、选择构建工具Maven Project、Spring Boot版本1.5.11以及一些工程基本信息,点击“Switch to the full version.”java版本选择1.8,可参考下图所示:

3、点击Generate Project下载项目压缩包

4、解压后,使用eclipse,Import -> Existing Maven Projects -> Next ->选择解压后的文件夹-> Finsh,OK done!

SpringBoot系列二:搭建自己的第一个SpringBoot程序的更多相关文章

  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学习笔记:2.搭建你的第一个springboot应用

    1.开发环境 (推荐):jdk1.8+Maven(3.2+)+Intellij IDEA+windows10; 说明: jdk:springboot官方说的很明确,到目前版本的springboot(1 ...

  3. Azure DevOps (十二) 通过Azure Devops部署一个SpringBoot应用

    文章配套视频专栏: https://space.bilibili.com/38649342/channel/seriesdetail?sid=2267536 视频正在努力更新. 上一篇文章中,我们通过 ...

  4. CodeBlocks环境搭建及创建第一个C++程序

    某业界大牛推荐最佳的途径是从raytracing入门,所以本屌开始学习<Ray Tracing In One Weekend>. 该书是基于C++的.本屌从未学过C++.感觉告诉我,要先搭 ...

  5. C# JabLib系列之如何保证只运行一个应用程序的实现

    保证只运行一个应用程序的C#实现: using System;using System.Collections.Generic;using System.Linq;using System.Windo ...

  6. springboot系列二、springboot项目搭建

    一.官网快速构建 1.maven构建项目 1.访问http://start.spring.io/ 2.选择构建工具Maven Project.Spring Boot版本2.1.1以及一些工程基本信息, ...

  7. SpringBoot系列二:SpringBoot自动配置原理

    主程序类的注解 @SpringBootApplication 注解,它其实是个组合注解,源码如下: @Target({ElementType.TYPE}) @Retention(RetentionPo ...

  8. (二十三)IDEA 构建一个springboot工程,以及可能遇到的问题

    一.下载安装intellij IEDA 需要破解 二.创建springboot工程 其他步骤省略,创建好的工程结构如下图: 三.配置springoboot工程 3.1 如上图src/main目录下只有 ...

  9. springcloud系列二 搭建注册中心启动

    创建modul 然后就创建完成了 添加yml文件: server: port: eureka: client: register-with-eureka: false #单机版建议设置为false,设 ...

随机推荐

  1. step-by-step-creating-a-sql-server-2012-alwayson-availability-group/

    https://blogs.technet.microsoft.com/canitpro/2013/08/19/step-by-step-creating-a-sql-server-2012-alwa ...

  2. NLP资料

    https://towardsdatascience.com/how-to-get-started-in-nlp-6a62aa4eaeff?source=rss-299377188126------3

  3. iOS 10.3.3 更新背后的故事

    iOS 10.3.3 更新背后的故事 TLDR:赶紧升级! 苹果最近提示大家将系统升级到 iOS 10.3.3,并且描述这个更新的内容是:修复和改进安全性. iOS 10.3.3 includes b ...

  4. 【C/C++】程序如何来,编译全过程

    概述    编译的目的是把人书写的高级语言代码翻译成目标程序的语言处理程序,编译用的程序(例如gcc)称为编译系统. 一个编译系统把一个源程序翻译成目标程序的工作过程分为5个阶段:词法分析.语法分析. ...

  5. 将map中的查询参数拼装到URL路径中

    被调接口的URL路径: //被调接口url String apiUrl = "http://api.open.xxxxxx.com/implatform/interview/send?acc ...

  6. mac下增加eclipse内存

    在mac上找不到eclipse.ini文件编辑内存限制,在eclipse安装目录右击eclipse程序,选“显示包内容”,eclipse.ini就在 Content/MacOS下.

  7. Lintcode: Interleaving Positive and Negative Numbers 解题报告

    Interleaving Positive and Negative Numbers 原题链接 : http://lintcode.com/zh-cn/problem/interleaving-pos ...

  8. SQLite 入门教程一 基本控制台(终端)命令

    一.基本简介 SQLite 是一个自持的(self-contained).无服务器的.零配置的.事务型的关系型数据库引擎.因为他很小,所以也可以作为嵌入式数据库内建在你的应用程序中.SQLite 被应 ...

  9. 三者互ping,PC,虚拟机,uboot,nfs网络文件系统搭建

    要想实现三者互ping,韦老师虽然专门出了视频说明,但是在自己配置过程还是出现了问题,这里记录一下解决办法,虽然我也不知道原因,但是解决了出现的问题也实现了三者互ping. 首先,我的硬件设备是PC通 ...

  10. 1. K-Means原理解析

    1. K-Means原理解析 2. K-Means的优化 3. sklearn的K-Means的使用 4. K-Means和K-Means++实现 1. 前言 我们在一开始的时候应该就说过,机器学习按 ...