一. Idea构建一个springboot项目
1)
2)
3) 将红标的后缀改为yml
同时将连接数据库进行配置:
spring:
datasource:
##driver-class-name: com.mysql.jdbc.Driver
url: jdbc:mysql://localhost:3306/test
data-username: root
data-password: 123456
mybatis:
type-aliases-package: com.rimi.cs.springbootdemo.pojo
mapper-locations: classpath:mapper/*Mapper.xml
4) 测试是否成功,运行该程序即可
如果出现下图即为成功
二. 编写测试Helloword
package com.wwspringtest.demo;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class HelloWord {
@GetMapping("/112")
@ResponseBody
public String HelloWord(){
return "helloword";
}
}
页面访问接口:http://localhost:8080/112
访问成功!