SpringBoot入门案例-阿里云版和纯手工版

不会压弯的小飞侠 发表于 2022/08/09 00:05:57 2022/08/09
【摘要】 文章目录 文章目录 文章目录前言一、阿里云版1.新增模块2.springboot联网功能3.选择当前模块需要使用的技术集4.控制类5.测试 二、纯手工版1.新建模板-Maven2.修改模块位...

文章目录


前言

阿里云版和纯手工版详细步骤:
在这里插入图片描述

一、阿里云版

1.新增模块

  1. File
  2. Project Structure
  3. Spring Initializr
  4. 更改Initializr Service URL 为:https://start.aliyun.com
    在这里插入图片描述

2.springboot联网功能

注意:java version与自己配置的jdk版本保持一致
在这里插入图片描述

3.选择当前模块需要使用的技术集

  • 根据自己的需求选择
  • 选择web
  • 选择SpringWeb
    在这里插入图片描述

4.控制类

package com.jkj.controller;

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

@RestController
@RequestMapping("/booksThree")
public class BookController {
    @GetMapping
    public String ById(){
        System.out.println("springboot_03 is running...");
        return "springboot_03 is running...";
    }
}

  
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15

5.测试

在这里插入图片描述
在这里插入图片描述

二、纯手工版

1.新建模板-Maven

  1. File
  2. Project Structure
  3. Maven
    在这里插入图片描述

2.修改模块位置

在这里插入图片描述
在这里插入图片描述

3.配置依赖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.jkj</groupId>
    <artifactId>springboot_05</artifactId>
    <version>1.0-SNAPSHOT</version>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.7.1</version>
    </parent>
    <description>Demo project for Spring Boot</description>
    <properties>
        <java.version>1.8</java.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

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



</project>

  
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35

4.编写Application入口类

package com.jkj;

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

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


  
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12

5.控制类

package com.jkj.controller;

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

@RestController
@RequestMapping("/bookFive")
public class BookController {
    @GetMapping
    public String ById(){
        System.out.println("springboot_05 is running...");
        return "springboot_05 is running...";
    }
}


  
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16

6.测试

在这里插入图片描述
在这里插入图片描述

文章来源: blog.csdn.net,作者:不会压弯的小飞侠,版权归原作者所有,如需转载,请联系作者。

原文链接:blog.csdn.net/qq_43514330/article/details/125673623

【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件至:cloudbbs@huaweicloud.com进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容。
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。