工具:idea
创建maven文件
导入依赖,在pom.xml中(在spring boot的官方文档找)
<!-- spring工程中需要继承的父工程 --><parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>2.7.6</version></parent><dependencies><dependency><!-- web开发的起步依赖 --><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency></dependencies>
创建controller
加注释,如果注释爆红就ALT+Enter,添加Maven依赖项
package test;import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;@RestController
public class HelloController {@RequestMapping("/qtds")public String Hello(){return "qtds";}
}
创建Application(在根目录)//引导类 springboot项目的入口
package test.controller;import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;@RestController
public class HelloController {@RequestMapping("/qtds")public String Hello(){return "Hello qtds";}
}
前面改了一下结构,
package test;import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;@SpringBootApplication
public class HelloApplication {public static void main(String[] args) {SpringApplication.run(HelloApplication.class);}
}
点击主函数进行运行
出现bug,
java: 无法访问org.springframework.web.bind.annotation.RequestMapping
错误的类文件: /C:/Users/向阳/.m2/repository/org/springframework/spring-web/6.0.7/spring-web-6.0.7.jar!/org/springframework/web/bind/annotation/RequestMapping.class
类文件具有错误的版本 61.0, 应为 52.0 请删除该文件或确保该文件位于正确的类路径子目录中。
把pom.xml中的多余依赖删除
再次运行
bug解决方法
解决方法2
再次运行成功后打开浏览器输入localhost:8080+路径
yeeeeeeeeeee
i am so proud of myself
kisskiss
没关系!!!只会一点点也已经很棒了!!!情绪稳定一分钟也已经很棒了!!!!!!
除了在工作室呆的很冷
晚上和室友去吃夜宵,今晚微醺!!!!最近是有一点幸福的,每件事都很再努力一把的感觉,数据结构复习完了,九价的第一针也大了,快递在路上了,准备挂耳染,等天气暖和和室友一起穿新买的好看衣服,今天还是星期五,晚上可以看vox的奥数,好幸福捏