- 打开Microsoft SQL Server Management Studio 18
- 点开:安全性-登录名-找到需要操作的数据库名称,右键点击选择属性
- 选择状态,按图中操作
- 桌面右键点击我的电脑,选择管理
- 依次展开服务和应用程序—SQL Server配置管理器—SQL Server网络配置—MSSQLSERVER的协议,然后右键点击TCP/IP选择启用
- 右键点击TCP/IP选择属性、选择IP地址,将所有的IP地址改为127.0.0.1,将TCP端口号改为1433,将所有已启动改为是,如图即可
7. 在Microsoft SQL Server Management Studio 18中重启服务
1.新建springboot项目
2. 建包
3. 编写配置文件application.yml
spring:
datasource:
driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
url: jdbc:sqlserver://localhost:1433;database=new_admin
username: sa
password: 123456
mybatis:
type-aliases-package: com.test3.mapper
mapper-locations: classpath:mapper/*Mapper.xml
- 配置启动类的扫描包
5.添加测试类- controller
package com.test3.controller;
import com.test3.server.StudentServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
public class StudentController {
@Autowired
private StudentServer studentServer;
@RequestMapping("/stu")
@ResponseBody
public Object selectStudentAll(){
return studentServer.studentAll();
}
}
- server层
package com.test3.server;
import java.util.List;
import java.util.Map;
public interface StudentServer {
List
package com.test3.server.Impl;
import com.test3.mapper.StudentMapper;
import com.test3.server.StudentServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
@Service
public class StudentServerImpl implements StudentServer {
@Autowired
private StudentMapper studentMapper;
@Override
public List
- mapper层
package com.test3.mapper;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
import java.util.Map;
public interface StudentMapper {
List
- resources包下的mapper文件夹下的xml文件对应Java包下的mapper



