因为网络原因,我们在使用idea的Spring Initializr创建springboot项目时经常会连接失败。
所以我们需要手动创建springboot项目
1、创建个简单的maven项目
2、引入springboot必要的依赖
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.6.5</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
3、添加application.properties配置文件,如果不添加会默认使用8080端口
主要是添加
server.port = 8080
4、添加Application 启动类
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class);
}
}
5、添加HelloController
@RestController
public class HelloController {
@RequestMapping("/hello")
public String hello() {
return "hello world";
}
}
6、启动