配置

——选择需要的依赖
springboot与mybatis结合
springboot与mybatis结合
springboot与mybatis结合
——如果连接sql 数据库,则需要自己导入sql依赖和jdbc桥梁包
springboot与mybatis结合springboot与mybatis结合

——添加插件,在settings里,点击红笔2标的地方,下载这两个插件,我的已经下载下来了springboot与mybatis结合
——找到文件的头文件,然后复制头文件
springboot与mybatis结合
——在res下见一个mapper文件夹,然后在建文件(建文件夹是为了便于区分),然后把头文件复制进去,再建dao层,dao层只需要一个接口类就可以(interface),然后把类的路径放进6中去
springboot与mybatis结合
——在DemoApplication中加上dao包的路径,告诉他这个包是处理和数据库连接的包
springboot与mybatis结合
——这是dao类中,方法的参数要加上@Param("") “”里面写参数名
springboot与mybatis结合
——1是dao方法里的方法名,2是返回的类型
springboot与mybatis结合
**

还有一种方法是注解式的,

**
1、先建一个mapper文件夹,

@Repository
public interface ITxlmapper {

    @Select(value = "select * from txl")
    List<Txl> gettxl();
    //    @interface ()
	//    @Update()···
}

这个是dao层
2、然后在DemoApplication 类上加上注解

@SpringBootApplication
@MapperScan("com.example.demo.mapper")
public class DemoApplication {

    public static void main(String[] args) {
        SpringApplication.run(DemoApplication.class, args);
    }
}

相关文章:

  • 2021-09-21
  • 2021-11-12
  • 2021-04-22
  • 2021-04-17
  • 2021-05-24
  • 2021-09-26
  • 2021-07-04
  • 2022-12-23
猜你喜欢
  • 2021-09-19
  • 2022-02-01
  • 2021-07-31
  • 2022-12-23
  • 2021-10-31
  • 2021-07-14
相关资源
相似解决方案