关于idea搭建SpringBoot启动时:Process finished with exit code 0解决办法

以前都用eclipse的,最经看springboot书籍,使用idea(springboot initializr)快速搭建springboot项目,一路next;

关于idea搭建SpringBoot启动时:Process finished with exit code 0解决办法

启动时候:Process finished with exit code 0,这不是错;

意思是:这个表示程序正常执行完毕退出了。

这就表示项目启动成功后了,此时运行,最后运行完毕自动退出。

关于idea搭建SpringBoot启动时:Process finished with exit code 0解决办法

而现在我们想要的是启动项目访问路径,我们需要的是springmvc的框架(可以使用一些注解如:@RestController,@RequestMapping),在springboot里面我们需要引入web这个依赖;

<dependency>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-starter-web</artifactId>
</dependency>
然后添加代码:

关于idea搭建SpringBoot启动时:Process finished with exit code 0解决办法

然后启动即可(默认是8080,如果想修改端口号修改配置文件,application.yml):

http://localhost:8080/