1. Load Driver
2, Configuration Application.properties
Spring.datasource.driverclassname=com.mysql.jdbc.driver
Spring.datasource.url=jdbc:mysql://192.168.0.104:3306/qiqisx
Spring.datasource.username=root
spring.datasource.password=666666
3, Springboot automatic equipment DataSource and JdbcTemplate
Spring.datasource.type can specify which data source to use, provided it has a dependent package
The default supports four kinds of DataSourceConfiguration.tomcat.class,
DataSourceConfiguration.Dbcp.class
DataSourceConfiguration.Dbcp2.class
DataSourceConfiguration.Hikari.class
Configuring a custom Dataresource only needs to be configured with a DataSource to the spring container, and Springboot takes precedence over the custom datasource
Enable Things
@EnableTransactionManagement
Add @transational to the way you need things
@Transational (Rollbackfor=exception.class) is in effect for runtime exceptions by default
@Transational (Norollbackfor=nullpointexception.class)
Things will not work, with the method of direct invocation There is no annotation, with the method within the method has no matter
________________SPRINGBOOTのJDBC, things