我是一个对idea喜欢但是有是一个新手,说的不好,各位老大多多包涵。

我是这个月才开始下载完idea2018版,网上教程都是2018之前的,现今应该还没有吧,本人买的是正版idea 搭建spring-boot

进去界面是有点小帅,没更新完,尽量今天完成

idea 搭建spring-boot


打开进去之后,new一个project

idea 搭建spring-boot


idea 搭建spring-boot

使用默认的就行了,然后next

idea 搭建spring-boot

因为这个只是单机版,所以这样就ok了如果不了解的话百度!

最重要的

idea 搭建spring-boot

点选web然后next,在frist完成就ok了

接下来有俩个分支

1.是没有页面,后台直接输出前端

因为在idea搭建springboot项目同时,他已经帮你写好启动类,注解是

@SpringBootApplication

SpringApplication.run(DemoApplication.class

这个是启动方法,你也可以进去看看ctrl+1

idea 搭建spring-boot

新建一个Controller类,@RestController和@Controller区别是在复合注解。

写完Hello word方法之后,就回到启动类,跟eclipse启动差不多,只不过这个是main方法启动,然后

idea 搭建spring-boot


idea 搭建spring-boot


第二种:@Controller注解,如果要使用,就要配合页面进行页面输出

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>

加了这个依赖后,在templates目录下新建目录也行,或者直接放到templates下也行。

idea 搭建spring-boot

idea 搭建spring-boot

还是那个Controller类,用ModelAndView去进行页面跳转,因为我这个是@RestController,所以不能直接跳转,如果是@Controller,String返回类型,就直接能跳转

idea 搭建spring-boot

相关文章:

  • 2022-12-23
  • 2021-11-03
  • 2021-10-10
  • 2021-10-18
  • 2022-01-10
  • 2021-08-02
  • 2021-04-09
  • 2021-06-06
猜你喜欢
  • 2021-12-02
  • 2022-12-23
  • 2021-10-10
  • 2021-12-13
  • 2021-07-21
  • 2022-03-03
  • 2021-04-03
相关资源
相似解决方案