一、进行一个maven仓库设置
Configure -> Setting
二、对仓库进行修改
三、在pom.xml加入依赖,记住层级关系。
<parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.1.0.RELEASE</version> </parent>
<dependencies> <dependency> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> <version>2.1.0.RELEASE</version> </dependency> </dependencies>
四、测试
在入口程序中,写一段测试代码
@EnableAutoConfiguration 自动配置
@RestController 页面控制台
@RequestMapping("/") 根目录
import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; /** * Unit test for simple App. */ @EnableAutoConfiguration @RestController public class AppTest { @RequestMapping("/user") public String home(){ return "Hello world"; } public static void main(String[] args) { System.out.println("Hello World!"); SpringApplication.run(AppTest.class, args); } }
五、运行springboot,会有如下日志打印
六、在网页中输入localhost:8080/
到此一个简单的springboot就搭建成功了。