SpringBoot中的Mybatis依赖问题怎么解决(mybatis,springboot,开发技术)

时间:2024-04-28 04:12:31 作者 : 石家庄SEO 分类 : 开发技术
  • TAG :

Pom导入依赖

<dependency><groupId>org.mybatis.spring.boot</groupId><artifactId>mybatis-spring-boot-starter</artifactId><version>2.0.0</version></dependency>

application.yml

#配置数据源,yml格式spring:datasource:url:jdbc:mysql://127.0.0.1:3306/dianping?useUnicode=true&characterEncoding=utf8username:rootpassword:123driver-class-name:com.mysql.jdbc.Driver#指定mybatis映射文件的地址mybatis:mapper-locations:classpath:mapper/*.xml

项目结构

SpringBoot中的Mybatis依赖问题怎么解决

mybatis默认是属性名和数据库字段名一一对应的,即
数据库表列:user_name
实体类属性:user_name

但是java中一般使用驼峰命名
数据库表列:user_name
实体类属性:userName

在Springboot中,可以通过设置map-underscore-to-camel-case属性为true来开启驼峰功能。
application.properties中:

mybatis:configuration:map-underscore-to-camel-case:true

补充:下面再看下spring boot集成mybatis需要的相关依赖

<dependencies><!--单元测试--><dependency><groupId>junit</groupId><artifactId>junit</artifactId><scope>test</scope></dependency><!--springboot对面向切面编程的支持,包括spring-aop和aspectj--><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-aop</artifactId><!--通过spring-rabbit来支持AMQP协议--><artifactId>spring-boot-starter-amqp</artifactId><!--对全栈web开发的支持,包括tomcat和spring-webmvc--><artifactId>spring-boot-starter-web</artifactId><!--TODO发布生产的时候需要将此段放开--><!--<exclusions>--><!--<exclusion>--><!--<groupId>org.springframework.boot</groupId>--><!--<artifactId>spring-boot-starter-tomcat</artifactId>--><!--</exclusion>--><!--</exclusions>--><!--支持常规的测试依赖,包括junit,hamcrest.mockito以及spring-test--><artifactId>spring-boot-starter-test</artifactId><!--生产准备的特征,用于帮你监控和管理应用--><artifactId>spring-boot-starter-actuator</artifactId>     <!--核心springbootstarter,包括自动配置支持,日志和YAML-->     <dependency><groupId>org.mybatis.spring.boot</groupId><artifactId>spring-boot-starter</artifactId>     <!--对jdbc数据库的支持--><artifactId>spring-boot-starter-jdbc</artifactId>     <!--对spring-security的支持--><artifactId>spring-boot-starter-security</artifactId>     <!--对spring-redis的支持,支持Redis键值存储数据库--><artifactId>spring-boot-starter-redis</artifactId><!--mybatis--><artifactId>mybatis-spring-boot-starter</artifactId><version>1.1.1</version><!--MYSQL--><groupId>mysql</groupId><artifactId>mysql-connector-java</artifactId><groupId>com.alibaba</groupId><artifactId>fastjson</artifactId><version>1.2.30</version><artifactId>druid</artifactId><version>1.0.24</version><groupId>org.hibernate</groupId><artifactId>hibernate-validator</artifactId><version>5.3.1.Final</version><groupId>javax.servlet</groupId><artifactId>javax.servlet-api</artifactId><version>3.0.1</version><scope>provided</scope><groupId>commons-httpclient</groupId><artifactId>commons-httpclient</artifactId><version>3.1</version><!--pagehelper--><!--<dependency><groupId>com.github.pagehelper</groupId><artifactId>pagehelper-spring-boot-starter</artifactId></dependency>--><groupId>com.github.pagehelper</groupId><artifactId>pagehelper</artifactId><version>4.1.6</version></dependency></dependencies>
 </div> <div class="zixun-tj-product adv-bottom"></div> </div> </div> <div class="prve-next-news">
本文:SpringBoot中的Mybatis依赖问题怎么解决的详细内容,希望对您有所帮助,信息来源于网络。
上一篇:如何使用instantclient客户端连接oracle数据库下一篇:

7 人围观 / 0 条评论 ↓快速评论↓

(必须)

(必须,保密)

阿狸1 阿狸2 阿狸3 阿狸4 阿狸5 阿狸6 阿狸7 阿狸8 阿狸9 阿狸10 阿狸11 阿狸12 阿狸13 阿狸14 阿狸15 阿狸16 阿狸17 阿狸18