springboot1.0,2014年发布, the default database connection pool for JDBC Pool Tomcat
springboot2.0, 2018 Nian 3 Yue 1 release, the default database connection pool for Hikari
1. Create a project selected components: mysql, jdbc web
application.yml 里:
the Spring:
the DataSource:
username: root
password: root
# using the MySQL connection driver is 8.0 or more, need to add time zones Url behind, GMT% 2B8 on behalf of China time zone, or area timekeeping
error
url: jdbc: mysql: //127.0.0.1: 3306 / jdbc serverTimezone = GMT 2B8%?
# Note: the new version of the driver package, use the following classes as a driving class
driver-class-name: com.mysql.cj.jdbc.Driver
@RestController注解=@Controller+@ResponseBody
druid
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.1.12</version>
</dependency>
mybatis
create project selection mybatis, jdbc, mysql web
@MapperScan ( "com.mengxuegu.springboot.mapper") automatically assembling all of the following specified package Mapper, save the
write @Mapper above each Mapper
Mybatis official website: http://www.mybatis.org/mybatis-3/zh/index.html
the mybatis usually xml way, with small projects only way to comment
Create the following directories and core profile mybatis-config.xml and mapper mapping folder resources
under mapper usually installed xxmapper.xml
mybatis-config.xml in hump plus maps
<the Configuration>
<-! core configuration file ->
<Settings>
<Setting name = "mapUnderscoreToCamelCase" value = "to true" />
</ Settings>
</ the Configuration>
application.yml 里
# Configure mybatis relevant file path
mybatis:
# mapping configuration file path
Mapper-locations: the CLASSPATH: mybatis / Mapper / * xml.
# Core configuration file path
config-location: classpath: mybatis / mybatis-config.xml
IOexception
servletexception
SQLException
InterruptedException
MessagingException
UnknownHostException
RuntimeException