创建springboot项目超级详细
application.properties
#配置端口
server.port=8080
#配置连接数据库
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/mysqldb
spring.datasource.username=root
spring.datasource.password=root
#指定mapper文件的位置
mybatis.mapper-locations=classpath:mapper/*.xml
#mybatis日志实现
mybatis.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl
StudentController
@Controller
public class StudentController {
@Resource
private StudentService studentService;
@RequestMapping("/student/query")
@ResponseBody
public String queryStudent(Integer id){
Student student = studentService.queryStudent(id);
return student.toString();
}
}
service
public interface StudentService {
Student queryStudent(Integer id);
}
@Service
public class StudentServiceImpl implements StudentService {
@Resource
StudentDao studentDao = null;
@Override
public Student queryStudent(Integer id) {
Student student