官网
https://spring.io
https://spring.io初始样例
package com.zzb.controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
//Rest模式
@RestController //该类将处理来自客户端的HTTP请求。
@RequestMapping("/books") //映射一个路径到请求处理方法。
public class Bookcontroller {
@GetMapping
public String getByid(){
System.out.println("springboot is running...");
return "springboot is running...";
}
}
错误
改成2.4.5
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.4.5</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
控制台信息
创建springboot项目
联网
方法一
方法二
https://start.aliyun.com
不联网
1.创建一个maven空工程
2.maven依赖
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.4.5</version>
</parent>
3.创建app
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class);
}
}
4.创建controller
5.运行app
隐藏文件
比较依赖版本
引导类
tomcat如何起来
不用tomcat
换一个
内置服务器
rest风格
idea复制工程
配置文件
三种配置文件