一. 学习springboot之路
主要记录搭建Springboot,访问成功案例
二. 新建一个maven项目,编写一个接口测试
- 新建一个项目,在pom.xml导入jar,如下配置:
测试项目结构如图
pom.xml配置:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>1.3.2</version>
</dependency>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
- 写一个Springboot启动类
@SpringBootApplication
public class SpringBoot2Application {
public static void main(String[] args) {
SpringApplication.run(SpringBoot2Application.class, args);
}
}
- 写一个Controller测试请求
@RequestMapping("/")
public class HelloController {
@RequestMapping("hello")
public String test() {
return "Hello Spring boot";
}
}
- 启动访问测试:
4.1 启动没有报错,正常启动成功
4.2 测试访问路径URL :http://localhost:8080/hello
测试访问成功
一个简单的SpringBoot项目就搭建成功啦