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,设 ...
随机推荐
- FLINK 设计文档
https://cwiki.apache.org/confluence/display/FLINK/Apache+Flink+Home https://cwiki.apache.org/conflue ...
- js中实现对checkbox选中和取消
可以使用 element.attr('checked','checked') 来进行选中.但是不能使用 element.attr('checked','false') 来取消选中. 必须通过以下方式: ...
- win2008r2的iis7.5手动建站方法,iis7.5中用独立用户建立网站的方法,提高网站安全性
win2003的iis6手动建站方法,iis6中用独立用户建立网站的方法,提高网站安全性,我们前面的教程有说明,请看http://www.piis.cn/zhishi/web574.asp 现在我们说 ...
- (原创)用C++11的std::async代替线程的创建
c++11中增加了线程,使得我们可以非常方便的创建线程,它的基本用法是这样的: void f(int n); std::thread t(f, n + ); t.join(); 但是线程毕竟是属于比较 ...
- mysql--Ubuntu下设置MySQL字符集为utf8
1.mysql配置文件地址/etc/mysql/my.cnf 2.在[mysqld]在下方添加以下代码[mysqld]init_connect='SET collation_connection = ...
- 每日英语:China Pipeline Explosions Kill 52
BEIJING—The death toll from a pair of oil pipeline explosions on Friday in the eastern China port ci ...
- DIOCP-开源项目ECHO测试.
DIOCP自开源以来,得到了很多朋友的测试,并进行了诸多的改进,现在已经运用到了一些具体的项目当中. DIOCP底层运行稳定. 昨天做了个ECHO测试,这个连接数并没有达到上限. 11K 连接,1个半 ...
- vue2.0的生命周期
生命周期先上图 什么是生命周期 Vue实例有一个完整的生命周期,也就是从开始创建.初始化数据.编译模板.挂载Dom.渲染→更新→渲染.卸载等一系列过程, 我们称这是Vue的生命周期.通俗说就是Vue实 ...
- hive添加UDF
hive添加UDF 步骤如下: 函数分为永久和临时函数,后者会话退出则消失,前者不会 查看已有函数(创建好后也可以通过这个来查看是否成功) show functions; 写UDF的java文件,如: ...
- Vue之vuex实现简易计算器
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...