SpringBoot系列二:搭建自己的第一个SpringBoot程序
声明:本文来源于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程序的更多相关文章
- [.NET MVC4 入门系列01]Helloworld MVC 4 第一个MVC4程序
[.NET MVC4 入门系列01]Helloworld MVC 4 第一个MVC4程序 一.练习项目: http://www.asp.net/mvc/tutorials/mvc-4/gettin ...
- springboot学习笔记:2.搭建你的第一个springboot应用
1.开发环境 (推荐):jdk1.8+Maven(3.2+)+Intellij IDEA+windows10; 说明: jdk:springboot官方说的很明确,到目前版本的springboot(1 ...
- Azure DevOps (十二) 通过Azure Devops部署一个SpringBoot应用
文章配套视频专栏: https://space.bilibili.com/38649342/channel/seriesdetail?sid=2267536 视频正在努力更新. 上一篇文章中,我们通过 ...
- CodeBlocks环境搭建及创建第一个C++程序
某业界大牛推荐最佳的途径是从raytracing入门,所以本屌开始学习<Ray Tracing In One Weekend>. 该书是基于C++的.本屌从未学过C++.感觉告诉我,要先搭 ...
- C# JabLib系列之如何保证只运行一个应用程序的实现
保证只运行一个应用程序的C#实现: using System;using System.Collections.Generic;using System.Linq;using System.Windo ...
- springboot系列二、springboot项目搭建
一.官网快速构建 1.maven构建项目 1.访问http://start.spring.io/ 2.选择构建工具Maven Project.Spring Boot版本2.1.1以及一些工程基本信息, ...
- SpringBoot系列二:SpringBoot自动配置原理
主程序类的注解 @SpringBootApplication 注解,它其实是个组合注解,源码如下: @Target({ElementType.TYPE}) @Retention(RetentionPo ...
- (二十三)IDEA 构建一个springboot工程,以及可能遇到的问题
一.下载安装intellij IEDA 需要破解 二.创建springboot工程 其他步骤省略,创建好的工程结构如下图: 三.配置springoboot工程 3.1 如上图src/main目录下只有 ...
- springcloud系列二 搭建注册中心启动
创建modul 然后就创建完成了 添加yml文件: server: port: eureka: client: register-with-eureka: false #单机版建议设置为false,设 ...
随机推荐
- hi模板文件报乱码问题
1.h5模板在: Templates\common 2.出现乱码的都在Templates\common\tags 局部视图里. 3.页面顶部有引用(skin-Common_SubmmitCartPr ...
- Android 编程下将 Bitmap 转为 InputStream
某些情况下会用到这种非主流的转换方式,最近项目中用到,记录下. ByteArrayOutputStream baos = new ByteArrayOutputStream(); bm.compres ...
- 【Java Concurrency】sleep()、wait()、notify()、notifyAll()的用法与区别
>关于本文 本文介绍sleep().wait().notify().notifyAll()方法,主要要理解: sleep()和wait()的区别. wait()与notify().notifyA ...
- 前端复制粘贴clipBoard.js的使用
<!DOCTYPE html> <html> <head> <title>ClipBoard.js使用:修改HTML</title> < ...
- JAVA实现MD5加密算法(使用MessageDigest)
http://blog.csdn.net/ymc0329/article/details/6738711 *********************************************** ...
- 在XSLT中输出内容带有CDATA的XML节点
http://www.cnblogs.com/jaxu/archive/2013/03/13/2956904.html **************************************** ...
- SparkStreaming python 读取kafka数据将结果输出到单个指定本地文件
# -*- coding: UTF-8 -*- #!/bin/env python3 # filename readFromKafkaStreamingGetLocation.py import IP ...
- linespace函数
numpy.linspace numpy.linspace(start, stop, num=50, endpoint=True, retstep=False, dtype=None)[source] ...
- border属性
border 简写属性,用于把针对四个边框的属性设置在一个声明里 border-style 用于元素所有边框的样式,或者单独的为各边框设置样式 border-width 简写属性,用于为元素的所有边框 ...
- 基于jQuery仿去哪儿城市选择代码
基于jQuery仿去哪儿城市选择代码.这是一款使用的jQuery城市选择特效代码下载.效果图如下: 在线预览 源码下载 实现的代码. html代码: <div class="lin ...