系列文章目录
提示:这里可以添加系列文章的所有文章的目录,目录需要自己手动添加
例如:第一章 Python 机器学习入门之pandas的使用
SpringBoot基础学习3——入门案例(阿里云版)
提示:以下是本篇文章正文内容,下面案例可供参考
一、创建新的模块
(1)
(2)基于阿里云创建项目,地址:https://start.aliyun.com
二、编写开发控制类
package com.yan.controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
//Rest模式
@RestController
@RequestMapping("/books")
public class BookController {
@GetMapping
public String getById(){
System.out.println("SpringBoot is running...3");
return "SpringBoot is running...3";
}
}
运行自动生成的Application类,在浏览器输入下面的网址:
http://localhost:8080/books
运行结果:
三、其他
(1)注意事项
- 阿里云提供的坐标版本较低,如果需要使用高版本,进入工程后手工切换SpringBoot版本
- 阿里云提供的工程模板与Spring官网提供的工程模板略有不同
(2)小结
- 选择start来源为自定义URL
- 输入阿里云start地址
- 创建项目