In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly explains "how to solve the problem of Mybatis dependence in SpringBoot". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to solve the problem of Mybatis dependency in SpringBoot.
Pom import dependency
Org.mybatis.spring.boot mybatis-spring-boot-starter 2.0.0
Application.yml
# configure the data source in yml format: spring: datasource: url: jdbc:mysql://127.0.0.1:3306/dianping?useUnicode=true&characterEncoding=utf8 username: root password: 123 driver-class-name: com.mysql.jdbc.Driver# specify the address of the mybatis mapping file mybatis: mapper-locations: classpath:mapper/*.xml
Project structure
By default, mybatis corresponds one to one between the attribute name and the database field name, that is,
Database table column: user_name
Entity class attribute: user_name
But hump naming is commonly used in java
Database table column: user_name
Entity class attribute: userName
In Springboot, you can turn on the hump function by setting the map-underscore-to-camel-case property to true.
In application.properties:
Mybatis: configuration: map-underscore-to-camel-case: true
Add: let's take a look at the related dependencies required by spring boot to integrate mybatis
Junit junit test org.springframework.boot spring-boot-starter-aop spring-boot-starter-amqp spring-boot-starter-web Spring-boot-starter-test spring-boot-starter-actuator org.mybatis.spring.boot spring-boot-starter spring-boot-starter-jdbc spring-boot-starter-security spring-boot-starter-redis Mybatis-spring-boot-starter 1.1.1 mysql mysql-connector-java com.alibaba fastjson 1.2.30 druid 1.0.24 org.hibernate hibernate-validator 5.3.1.Final javax.servlet Javax.servlet-api 3.0.1 provided commons-httpclient commons-httpclient 3.1 com.github.pagehelper pagehelper 4.1.6 to this I believe that you have a deeper understanding of "how to solve the problem of Mybatis dependence in SpringBoot". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.