一、采用 Spring Initializr 搭建springboot应用
步骤:
1、只需要打开网址: https://start.spring.io/;
2、选择使用 Maven 构建,语言 java,Spring Boot 版本 2.0.4,group 为 com.shiyanlou,artifact 为 springboot,依赖我们选择 web。
点击 Generate Project,我们会得到一个 springboot.zip 的压缩包。
3、使用 Spirng Boot 的 maven 插件启动(运行 mvn spring-boot:run)

二、手动构建 Spring Boot 项目
步骤:
1、运行:mvn archetype:generate
mvn archetype:generate \
-DgroupId=com.shiyanlou \
-DartifactId = springboot \
-DarchetypeArtifactId = maven-archetype-quickstart
创建过程中会提示输入版本号等,直接使用默认即可。接着输入 Y 确定创建。

2、添加 maven 依赖,修改 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.shiyanlou</groupId>
<artifactId>springboot</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

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

<!--设置父模块 这样就可以继承父模块中的配置信息-->
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.4.RELEASE</version>
<relativePath/>
</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>
<!--添加web依赖-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>

<build>
<plugins>
<!--spirng Boot maven插件-->
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>

</project>
3、在包 com.shiyanlou.springboot 中建立 SpringbootApplication.java,代码如下:

package com.shiyanlou.springboot;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

// @SpringBootApplication 注解相当于同时使用 @EnableAutoConfiguration、@ComponentScan、@Configurations 三个注解
// @EnableAutoConfiguration 用于打开 Spring Boot 自动配置,而其余注解为 Spring 注解,这里不再赘述
@SpringBootApplication
public class SpringbootApplication{

public static void main(String[] args){
SpringApplication.run(SpringbootApplication.class, args);
}
}
4、打开 terminal,输入:mvn spring-boot:run;

三、先命令行创建mvn项目,在加入spring-boot依赖。
1. 命令行 mvn archetype:generate -DgroupId=com.shiyanlou -DartifactId=redis -DarchetypeArtifactId=maven-archetype-quickstart
一直回车就好了。
2. porm文件添加依赖:
<?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>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.2.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.shiyanlou</groupId>
<artifactId>redis</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>redis</name>
<description></description>

<properties>
<java.version>1.8</java.version>
</properties>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
3. 完成 o(n_n)o;

搭建 springboot 应用的更多相关文章

  1. 搭建 springboot 2.0 mybatis 读写分离 配置区分不同环境

    最近公司打算使用springboot2.0, springboot支持HTTP/2,所以提前先搭建一下环境.网上很多都在springboot1.5实现的,所以还是有些差异的.接下来咱们一块看一下. 文 ...

  2. 搭建SpringBoot+dubbo+zookeeper+maven框架(二)

    上一篇文章是关于搭建SpringBoot+dubbo+zookeeper+maven框架的,但是里面的功能还不够完善,今天就日志管理方面做一些改善. 下了demo的网友可能会发现项目在启动时会有警告: ...

  3. 快速搭建springboot框架以及整合ssm+shiro+安装Rabbitmq和Erlang、Mysql下载与配置

    1.快速搭建springboot框架(在idea中): file–>new project–>Spring Initializr–>next–>然后一直下一步. 然后复制一下代 ...

  4. 搭建SpringBoot服务器,在公司内网中使用

    搭建SpringBoot服务器,在公司内网中使用. 学习了:https://blog.csdn.net/z3881006/article/details/78902231 就是一个程序,托管于gith ...

  5. 在线官网Spring Initializr 或 IntelliJ IDEA 快速搭建springboot项目

    Spring Boot是由Pivotal团队提供的全新框架,设计目的是用来简化新Spring应用的初始搭建以及开发过程.它主要推崇的是'消灭配置’,实现零配置. 那么,如何快速新建一个一个spring ...

  6. (A)eclipse搭建springboot项目入门

    网上许多资料都是用idea的,但是我个人用eclipse习惯了,所以就在eclipse里面自己尝试着写了一个hello. 然而项目建好后却迟迟不能访问!!!网上搜了许多资料都不靠谱! 虽然最后能看到h ...

  7. SpringBoot从入门到精通一(idea优雅搭建SpringBoot项目)

    前言 在没有SpringBoot之前,我们搭建的是SSM(SpingMVC+Spring+Mybatis)项目,在搭建SSM项目的时候,我们要经过一系列的繁琐配置,例如:application,web ...

  8. 搭建Springboot

    这几天一直在研究IDEA上面怎么搭建一个web-mvc的SpringBoot项目,看网上的教程一步步的搭建,可是还是出现一堆的问题. 为了让大家以后少走一些弯路,我在这里分享一下我这几天研究的成果,也 ...

  9. eclipse搭建springboot的项目

    记录一次自己搭建springboot的经历 springboot项目创建 这里借用别的博主分享的方法 https://blog.csdn.net/mousede/article/details/812 ...

  10. 小D课堂-SpringBoot 2.x微信支付在线教育网站项目实战_2-2.快速搭建SpringBoot项目,采用IDEA

    笔记 2.快速搭建SpringBoot项目,采用IDEA     简介:使用SpringBoot start在线生成项目基本框架并导入到IDEA中 参考资料:         IDEA使用文档    ...

随机推荐

  1. React组件渲染触发的条件-归纳总结

    一.React组件何时发生渲染--何时会生成React元素? React组件的渲染发生在两个阶段. 1. 组件挂载. 2. 组件更新. 二.React组件更新的触发条件是什么? 对没有实现should ...

  2. ATM购物车大作业

    项目开发流程 1.需求分析:品经理与架构师,根据客户的需求,理出一套比较容易编写的流程 2.架构设计:架构师根据具体的业务需求选择 具体的开发编程语言与项目框架,所需要的数据库(主库,从库).与开发目 ...

  3. Java堆外缓存(一个很有意思的应用)

    我们在开发过程中会遇到这样的场景:就是一个服务的各项 JVM 的配置都比较合理的情况下,它的 GC 情况还是不容乐观.分析之后发现有 2 个对象特别巨大,占了总存活堆内存的 90%以上.其中第 1 大 ...

  4. Eclpis-cannot open git-receive-pack

    转载:https://blog.csdn.net/qq_29954971/article/details/80191193 问题:在采用MyEclipse软件(JDK1.7)作为开发环境,利用GitH ...

  5. P21_事件传参与数据同步

    事件绑定 在事件处理函数中为 data 中的数据赋值 通过调用 this.setData(dataObject) 方法,可以给页面 data 中的数据重新赋值,示例如下: 事件传参 小程序中的事件传参 ...

  6. 1.初识 Django

    设计模式 定义 # mysite/news/models.py from django.db import models class Reporter(models.Model): full_name ...

  7. SpringCloud 小知识和历史

    六Spring Cloud 回顾之前的: javaSE 数据库 前端 Servlet HTTP Mybatis Spring SpringMVC SpringBoot Dubbo.Zookeeper. ...

  8. Philips and Calculator

    代码 #include<cstdio> #include<algorithm> using namespace std; const int N = 3 * 1e6; int ...

  9. 按highcharts中column形式转对象展现格式

    highcharts图表type:column事例的格式是这样的: (不论接口返回什么格式,需要转换成下面这样的): xAxis: { categories: ['一月','二月'], }, seri ...

  10. JSP 与 Servlet 之间的联系,及其语法

    JSP 是什么 JSP 将 Java 代码和特定变动内容嵌入到静态的页面中,实现以静态页面为模板,动态生成其中的部分内容.JSP 文件在运行时会被其编译器转换成更原始的 Servlet 代码.JSP ...