Xiaotang began to learn Spring Boot - (1) IDEA 2021.3.2 and Maven installation configuration


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

1. Install Maven

download link

http://maven.apache.org
insert image description here
insert image description here
国外的网站会有点小慢,不过问题不大,解压之后随便放在一个盘里面

Configure Maven

因为Maven的源是国外的,在这里我们要改一下镜像,找到 apache-maven-3.8.4\conf目录下的settings.xml
insert image description here
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>

insert image description here记得保存

2. Install IDEA 2021.3.2

download link

https://www.jetbrains.com/idea/download/#section=windows
insert image description here
除了32和64位的选择那里,安装个人喜好来(不会就全选),其他一直点下一步
insert image description here

运行IDEA
insert image description here

Arrangement Chinese

我不喜欢英文,所以直接在下插件
insert image description here
insert image description here
重启
insert image description here
insert image description here

Configure Maven in IDEA

insert image description here
insert image description here

3. My first Spring Boot project

New Project

insert image description here
insert image description here
目录结构
insert image description here
点击运行
insert image description here

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

write page

insert image description here
insert image description here
insert image description here

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 "你好小唐!";
    }
}

start up

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

Guess you like

Origin blog.csdn.net/weixin_52521533/article/details/123479463