Spring Boot 001 环境配置以及初始化项目

知识储备

后端:JavaSE, SSM(Spring+SpringMVC+MyBatis)

前端:HTML, CSS, Javascript

环境准备

JDK17+下载

Java Downloads | Oracle

安装方式

JDK17在Windows安装以及环境变量配置(超详细的教程)_jdk17安装教程详细-CSDN博客

IDEA安装

其他版本 - IntelliJ IDEA (jetbrains.com.cn)

VS Code

Visual Studio Code - Code Editing. Redefined

MySQL8安装

MySQL8超详细安装教程_mysql8安装-CSDN博客

创建Spring Boot项目

使用IDEA创建

使用IDEA引到界面创建项目

认识一下项目文件

porn.xml

Application启动文件

编写control文件

package com.geji.controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HelloController {

    @RequestMapping("/hello")
    public String hello() {
        return "Hello World2~";
    }
}

启动application文件

打开网页查看

手动创建

创建Maven工程

porn.xml引入依赖

sprint boot工程

  <!--    boot工程的父工程,起步依赖的版本管理   -->
  <parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>3.1.8</version>
    <relativePath/> <!-- lookup parent from repository -->
  </parent>

起步依赖

    <!--web起步依赖,没有写版本号,因为上面parent继承了-->
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

刷新porn.xml

编写启动类,改名字

编写启动文件

package com.geji;

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

/**
 * Hello world!
 *
 */
@SpringBootApplication
public class SpringBootCreateManuallyApplication
{
    public static void main( String[] args )
    {
        SpringApplication.run(SpringBootCreateManuallyApplication.class,args);
    }
}

创建resource目录

resource目录下创建application.properties

创建controller文件夹以及具体的文件

package com.geji.controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HelloController {

    @RequestMapping("/hello")
    public String hello() {
        return "Hello World2~";
    }
}

Spring Boot配置文件
propeties形式

修改端口号以及虚拟路径

打开网址验证效果

yaml形式

其他:yml文件的读取方式

另一种简单的方法

  • 3
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

机器人迈克猫

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

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

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

打赏作者

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

抵扣说明:

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

余额充值