小唐开始学 Spring Boot——(1)IDEA 2021.3.2和Maven的安装配置

271 阅读1分钟

本文已参与「新人创作礼」活动,一起开启掘金创作之路

小唐开始学习Spring Boot了啊哈哈哈哈哈哈哈哈哈哈

一、安装Maven

下载地址

maven.apache.org 在这里插入图片描述

在这里插入图片描述

国外的网站会有点小慢,不过问题不大,解压之后随便放在一个盘里面

配置Maven

因为Maven的源是国外的,在这里我们要改一下镜像,找到 apache-maven-3.8.4\conf目录下的settings.xml

在这里插入图片描述

txt啥的直接打开,找到 <mirror> </mirror>这样一组便签,他的里面应该没有东西的 ,把这个阿里的镜像加进去

<mirror>
            <id>alimaven</id>
            <mirrorOf>central</mirrorOf>
            <name>aliyun maven</name>
            <url>http://maven.aliyun.com/nexus/content/repositories/central</url>
        </mirror>

        <mirror>
            <id>alimaven</id>
            <name>aliyun maven</name>
            <url>http://maven.aliyun.com/nexus/content/groups/public</url>
            <mirrorOf>central</mirrorOf>
        </mirror>

在这里插入图片描述

记得保存

二、安装IDEA 2021.3.2

下载地址

www.jetbrains.com/idea/downlo…

在这里插入图片描述

除了32和64位的选择那里,安装个人喜好来(不会就全选),其他一直点下一步

在这里插入图片描述

运行IDEA

在这里插入图片描述

配置中文

我不喜欢英文,所以直接在下插件

在这里插入图片描述

在这里插入图片描述

重启

在这里插入图片描述

在这里插入图片描述

配置IDEA里面的Maven

在这里插入图片描述

在这里插入图片描述

三、 我的第一个 Spring Boot项目

新建项目

在这里插入图片描述

在这里插入图片描述

目录结构

在这里插入图片描述

点击运行

在这里插入图片描述

如果出现这个大logo 并且在 http://localhost:8080/ 看到这个,说明成功

在这里插入图片描述

在这里插入图片描述

编写页面

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

package com.example.frist;//每一个人的包名不一样
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
//注意我们的类名是否相同
public class hello {
    @GetMapping("/hello")//网址就是http://localhost:8080/hello
    //@GetMapping("/XXX") 网址就是http://localhost:8080/XXX
    public String hello(){
        return "你好小唐!";
    }
}

启动

重新启动程序,这样我们就可以在 http://localhost:8080/hello 看到我们的输出(后缀是依据我们@GetMapping的设置来的)

在这里插入图片描述

在这里插入图片描述