新建工程spring boot

使用Maven管理,

在官网(http://atart.spring.io)下载demo后,加入依赖

<dependency>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter-tomcat</artifactId>
         <!--<scope>provided</scope>-->
      </dependency>

pom.xml

<?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.example</groupId>
   <artifactId>demo</artifactId>
   <version>0.0.1-SNAPSHOT</version>
   <packaging>jar</packaging>

<name>demo</name>
   <description>Demo project for Spring Boot</description>

<parent>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-parent</artifactId>
      <version>1.5.1.RELEASE</version>
      <relativePath/> <!-- lookup parent from repository -->
   </parent>

<properties>
      <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
      <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
      <java.version>1.8</java.version>
   </properties>

<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>
      <dependency>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter-tomcat</artifactId>
         <!--<scope>provided</scope>-->
      </dependency>
   </dependencies>

<build>
      <plugins>
         <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
         </plugin>
      </plugins>
   </build>

</project>

DemoApplication.java

package com.example;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

//@SpringBootApplication
//public class DemoApplication {
//
// public static void main(String[] args) {
//
//    SpringApplication.run(DemoApplication.class, args);
//
// }
//}
@SpringBootApplication
@RestController
public class DemoApplication {

@RequestMapping("/")
   public String greeting() {
      return "Hello World!";
   }

public static void main(String[] args) {
      SpringApplication.run(DemoApplication.class, args);
   }
}

Just  run

在浏览器输入http://localhost:8080

新建工程spring boot的更多相关文章

  1. 使用Spring Boot搭建应用开发框架(一) —— 基础架构

    Spring的简史 第一阶段:XML配置,在Spring1.x时代,使用Spring开发满眼都是xml配置的Bean,随着项目的扩大,我们需要把xml配置文件分放到不同的配置文件里,那时候需要频繁的在 ...

  2. Spring Boot 2.0 配置图文教程

    摘要: 原创出处 https://www.bysocket.com 「公众号:泥瓦匠BYSocket 」欢迎关注和转载,保留摘要,谢谢! 本章内容 自定义属性快速入门 外化配置 自动配置 自定义创建 ...

  3. Spring Boot 2.0 的快速入门(图文教程)

    摘要: 原创出处 https://www.bysocket.com 「公众号:泥瓦匠BYSocket 」欢迎关注和转载,保留摘要,谢谢! Spring Boot 2.0 的快速入门(图文教程) 大家都 ...

  4. spring boot hello world

    本文讲解初始用户搭建spring boot 工程. 新建工程目录结构: application.java放在最外层的包目录里 先添加pom.xml的依赖包: <project xmlns=&qu ...

  5. Spring Boot + Mybatis + Redis二级缓存开发指南

    Spring Boot + Mybatis + Redis二级缓存开发指南 背景 Spring-Boot因其提供了各种开箱即用的插件,使得它成为了当今最为主流的Java Web开发框架之一.Mybat ...

  6. Spring Boot + Spring Cloud 实现权限管理系统 配置中心(Config、Bus)

    技术背景 如今微服务架构盛行,在分布式系统中,项目日益庞大,子项目日益增多,每个项目都散落着各种配置文件,且随着服务的增加而不断增多.此时,往往某一个基础服务信息变更,都会导致一系列服务的更新和重启, ...

  7. 从零开始学 Spring Boot

    1.下载 spring-tool-suite https://spring.io/tools3/sts/legacy 2.解压运行 sts-bundle\sts-3.9.7.RELEASE\STS.e ...

  8. Spring Boot + Spring Cloud 实现权限管理系统 后端篇(二十三):配置中心(Config、Bus)

    在线演示 演示地址:http://139.196.87.48:9002/kitty 用户名:admin 密码:admin 技术背景 如今微服务架构盛行,在分布式系统中,项目日益庞大,子项目日益增多,每 ...

  9. Spring Boot + Spring Cloud 构建微服务系统(九):配置中心(Spring Cloud Config)

    技术背景 如今微服务架构盛行,在分布式系统中,项目日益庞大,子项目日益增多,每个项目都散落着各种配置文件,且随着服务的增加而不断增多.此时,往往某一个基础服务信息变更,都会导致一系列服务的更新和重启, ...

随机推荐

  1. WPF属性之理解附加属性

    附加属性,顾名思义,和被附加的控件没有依赖关系,只是强行给目标控件挂上一个“属性值”,以便于操作之.就好比,你在学校是学生,那么就要听老师的管教,在公司是下属,就要服从老板的命令一样. 我们常见的附加 ...

  2. DataContract] [DataMember] 程序集引用

    引用,右键->添加引用->System.Runtime.Serialization 添加

  3. Hibernate入门2

    实体类的编写规则 要求实体类的属性是私有的 要求实体类中的私有属性有公开的get和set方法(设置器和访问器) 要求实体类有一个属性作为唯一值(一般使用id值) 实体类属性建议不使用基本数据类型,使用 ...

  4. 洛谷P2661 信息传递——并查集

    给一手链接 https://www.luogu.com.cn/problem/P2661 这道题就是 并查集求最小环 TIPS:压缩路径的时候d[x]=d[fa[x]]+d[x],而不是d[x]=d[ ...

  5. C#=> 栈模仿堆的操作

    //原理,利用两个栈,互相作用,来模仿堆的效果,先进先出.. using System; using System.Collections.Generic; using System.Linq; us ...

  6. Java并发编程:线程的创建

    Java并发编程:线程的创建 */--> code {color: #FF0000} pre.src {background-color: #002b36; color: #839496;} J ...

  7. java 进销存 商户管理 系统 管理 库存管理 销售报表springmvc SSM项目

    统介绍: 1.系统采用主流的 SSM 框架 jsp JSTL bootstrap html5 (PC浏览器使用) 2.springmvc +spring4.3.7+ mybaits3.3  SSM 普 ...

  8. 2019-9-8-WPF-渲染原理

    title author date CreateTime categories WPF 渲染原理 lindexi 2019-9-8 10:40:0 +0800 2018-7-15 16:2:47 +0 ...

  9. R语言ggplot2软件包

    相比r语言自带软件包,ggplot2有以下特色 图形语法的核心:统计图形是数据向几何对象属性的一个映射.

  10. 微信小程序(16)-- bindtap,catchtap事件绑定的区别

    bindtap,catchtap事件绑定的区别,这里就涉及冒泡事件了.bind事件绑定不会阻止冒泡事件向上冒泡,catch事件绑定可以阻止冒泡事件向上冒泡. logs.wxml <view cl ...