目录
一、快速创建项目
1、使用官网提供的spring组件创建一个springboot3工程,springboot3要使用JDK17以上的版本
选择配置点击finish,刷新maven
创建一个controller层,写一个demo,点击运行
@RestController
public class TestController {
@GetMapping("/hello")
public String hello(){
return "hello";
}
}
访问:localhost:8080/hello,返回hello说明工程创建成功
二、手动创建一个工程
1、选择maven工程,选择:maven-archetype-quickstart骨架
修改项目名称和包名
继承父工程
<parent>
<groupId>org.springframework.boot</groupId>
<version>3.2.3</version>
<artifactId>spring-boot-starter-parent</artifactId>
</parent>
添加web依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
修改启动类、
@SpringBootApplication
public class Test1Application
{
public static void main( String[] args )
{
SpringApplication.run(Test1Application.class,args);
}
}
写controller测试类
@RestController
public class TestController {
@GetMapping("/hello")
public String hello(){
return "hello~~~~~~~~~";
}
}
测试成功