Spring Boot可以轻松创建独立的,生产级的基于Spring的应用程序,他的特征:
    1、创建独立的Spring应用程序
    2、直接嵌入Tomcat,Jetty或Undertow(无需部署WAR文件)
    3、提供自己的'入门'POM来简化你的Maven配置
    4、尽可能自动配置Spring
    5、提供生产就绪功能,如指标,运行状况检查和外部配置

6、绝对不会生成代码,并且不需要XML配置

正如上面所说,不需要繁琐的xml配置,它的许多相关配置,都可以在application.properties里面完成,比如服务器应绑定到的网络地址,应用程序的上下文路径,Server HTTP端口,会话超时(秒),字符编码,访问日志目录等。

现在我们先来创建一个最简单的spring-boot:

如果你使用的是idea(不要社区版),其创建十分便捷:

第一步:点击File选择NEW PROJECT

选择next:

选填自己项目名和项目分组名,type为maven项目选项,然后点击next:

在这里初步选择自己web项目需要的jar包,如果是web项目一定需要选择web这个选项,如此项目中可以添加web项目依赖的jar包和pom配置:

<dependencies>
<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>

如果没有选择也没有关系,之后自己在pom文件中把这两个dependency添加进去就好了,然后自己从写下DemoApplication就可以了,DemoApplication是整个项目的启动类。

勾选web之后,我们就可以开始一个简单的web应用测试下:

自己手写一个controller:

package com.example.demo.contorller;

importorg.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; /**
* Created by yhw on 2018/5/23.
*/
@RestController
public class firstContorller { @RequestMapping("/")
public String returnIndex(){
return "god boy say hello";
} }

启动DemoApplication,之后,我们可以访问http://localhost:8080/,可以看到自己返回值已经在web页面了。

在这里需要注意的是我们写的controller还有service还有之后的dao层,都要在DemoApplication所在目录的子目录或者平级目录,否则项目启动无法访问到,我们可以这么理解,其子目录存在已经超过启动class能控制的范围。

JAVA---spring-boot入门(图文教程)的更多相关文章

  1. Spring Boot入门教程1、使用Spring Boot构建第一个Web应用程序

    一.前言 什么是Spring Boot?Spring Boot就是一个让你使用Spring构建应用时减少配置的一个框架.约定优于配置,一定程度上提高了开发效率.https://zhuanlan.zhi ...

  2. Spring Boot入门教程2-1、使用Spring Boot+MyBatis访问数据库(CURD)注解版

    一.前言 什么是MyBatis?MyBatis是目前Java平台最为流行的ORM框架https://baike.baidu.com/item/MyBatis/2824918 本篇开发环境1.操作系统: ...

  3. Spring Boot入门教程(1)

    Spring Boot入门教程(1) 本文将使用Spring Boot一步步搭建一个简单的Web项目来帮助你快速上手. 将要用到的工具 JDK 8 IntelliJ IDEA(Ultimate Edi ...

  4. spring boot入门教程——Spring Boot快速入门指南

    Spring Boot已成为当今最流行的微服务开发框架,本文是如何使用Spring Boot快速开始Web微服务开发的指南,我们将使创建一个可运行的包含内嵌Web容器(默认使用的是Tomcat)的可运 ...

  5. Spring Boot 入门教程

    Spring Boot 入门教程,包含且不仅限于使用Spring Boot构建API.使用Thymeleaf模板引擎以及Freemarker模板引擎渲染视图.使用MyBatis操作数据库等等.本教程示 ...

  6. spring boot入门与进阶教程

    SpringBoot入门.SpringBoot进阶.Spring Cloud微服务.Spring Ecosystem 微服务相关.Spring Boot 入门 IDEA 版本.Spring Boot集 ...

  7. Spring Boot 入门(五):集成 AOP 进行日志管理

    本篇文章是接着 Spring boot 入门(四):集成 Shiro 实现登陆认证和权限管理写的,按照前面几篇博客的教程,可以搭建一个简单的项目,主要包含了 Pagehelper+MyBatis 分页 ...

  8. Spring boot入门(二):Spring boot集成MySql,Mybatis和PageHelper插件

    上一篇文章,写了如何搭建一个简单的Spring boot项目,本篇是接着上一篇文章写得:Spring boot入门:快速搭建Spring boot项目(一),主要是spring boot集成mybat ...

  9. 161103、Spring Boot 入门

    Spring Boot 入门 spring Boot是Spring社区较新的一个项目.该项目的目的是帮助开发者更容易的创建基于Spring的应用程序和服务,让更多人的人更快的对Spring进行入门体验 ...

  10. spring boot 入门操作(二)

    spring boot入门操作 使用FastJson解析json数据 pom dependencies里添加fastjson依赖 <dependency> <groupId>c ...

随机推荐

  1. 【LeetCode】047. Permutations II

    题目: Given a collection of numbers that might contain duplicates, return all possible unique permutat ...

  2. EntityFramework Code First 构建外键关系,数据库不生成外键约束

    创建 ExtendedSqlGenerator类 public class ExtendedSqlGenerator : SqlServerMigrationSqlGenerator { #regio ...

  3. Mesos以及Marathon安装总结

    安装了将近一周的环境了,终于把Mesos以及Marathon给安装上了,我指的离线安装. 策略1: 严格的按照官网的流程: http://mesos.apache.org/gettingstarted ...

  4. codec can't decode byte 0xe6 in position 0: ordinal not in range

    ascii' codec can't decode byte 0xe6 in position 0: ordinal not in range(128)] 错误: 实例 "linux-cor ...

  5. function multi-versioning in GCC

    https://lwn.net/Articles/691932/ https://gcc.gnu.org/wiki/FunctionMultiVersioning why multi-versioni ...

  6. David Malan teaching CS75 lecture 9, Scalability

    https://youtu.be/-W9F__D3oY4 Storage PATA, SATA, SAS (15,000 rpm), SSD, RAID0 : striping, double thr ...

  7. apache配置中的小细节

    configuration error: couldn’t perform authentication错误的解决办法 configuration error: couldn’t perform au ...

  8. ubuntu安装vnc,远程链接时出现灰屏,配置文档不对吗

    摘自:https://zhidao.baidu.com/question/1949169099296473348.html 1.在Ubuntu上首先需要安装vnc4server # apt-get i ...

  9. Protobuf 文件生成工具 Prototool 命令详解

    Protobuf 文件生成工具 Prototool 命令详解 简介 Prototool 是 Protobuf 文件的生成工具, 目前支持go, php, java, c#, object c 五种语言 ...

  10. ue4 character 物理测试

    charactor里 CapsuleComponnet Mesh CharacterMovement 3个组件里有有物理开关 目前看Mesh的Simulate Physics+Enable Gravi ...