IDEA maven工程搭建springBoot框架(Hello World!)

本文参考:https://blog.youkuaiyun.com/qq_43006591/article/details/106137465?spm=1001.2014.3001.5506

今儿看到一个博主写的搭建文章,自己也做个笔记 废话不多说直接上图

1.File→New→Project
在这里插入图片描述
2.选择maven
在这里插入图片描述
3.输入项目名称和存放路径,点击Finish
在这里插入图片描述
4.随便选择,我一般选择 New Window(创建新的窗口)
在这里插入图片描述
5.窗口打开后稍微等一下,出来的界面是这样的
在这里插入图片描述
6.修改 pom.xml 文件,新增依赖

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.7.3</version>
    </parent>

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

7.报红线先不着急,一会再解决它。(图上的2.7.7有问题 我改为2.7.3了,图片上的版本号懒得改就这样吧,实在不清楚看下面pom文件的图片)
在这里插入图片描述
8.改完以后是这样的
在这里插入图片描述
9.然后解决爆红线问题
在这里插入图片描述
在这里插入图片描述
ok了
在这里插入图片描述
在这里插入图片描述

不爆红线略过这一步,如果还是报红线你看看你maven配的对不对,看图
在这里插入图片描述
我就这样没动,我这个就是搭建个demo玩玩,就没配项目需要的setting.xml文件和本地仓库,如果你需要配置公司或者网上的看这篇 :http://t.zoukankan.com/Durant0420-p-14816700.html
在这里插入图片描述

10.上面稍微说了一下maven配置,回归正题,下一步,创建一个包,名字随意,我这边叫 com.demo
在这里插入图片描述
在这里插入图片描述
11.再创建一个启动类,名字随意,我这边叫 SpringBootApplication
在这里插入图片描述

在这里插入图片描述
12.代码给你们,直接复制吧

package com.demo;

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

@RestController
@EnableAutoConfiguration //开启自动配置
public class SpringBootApplication {

    public static void main(String[] args) {
        SpringApplication.run(SpringBootApplication.class, args);
        System.out.println("给我一杯忘情水~");
    }
}





然后启动,输出结果: 给我一杯忘情水~
在这里插入图片描述

---------------------------2024年6月19日16:10:05----------------------------------------------------------
(PS:后期发现类名会跟注解撞上,请求接口路径会404,所以随意给个名字吧 AppApplication)

package com.demo;


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

@SpringBootApplication
public class AppApplication {

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



在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

七月吃橘子

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值