idea 普通项目转换成spring boot项目
-
在pom.xml中加入spring boot的parent(建议放在modelVersion后面):
org.springframework.boot
spring-boot-starter-parent
2.2.2.RELEASE
-
pom.xml中加入spring boot的依赖:
org.springframework.bootspring-boot-starter-testtestorg.junit.vintagejunit-vintage-engineorg.springframework.bootspring-boot-starter-web -
项目的根包(例如:com.iotedu.byloue)下添加一个新类:
@SpringBootApplication
public class ByloueApplication {public static void main(String[] args) {SpringApplication.run(ByloueApplication.class, args);}
}
-
新建一个controllers包,里面添加controller类:
@RestController
@RequestMapping(“/byloue”)
public class MainController {@RequestMapping("/hello")public String hello() { return "Hello world!"; }
}