markdown MySQL的常用语句
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了markdown MySQL的常用语句相关的知识,希望对你有一定的参考价值。
**Maven**
```xml
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<dependency><!--mybatis-->
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>1.3.1</version>
</dependency>
<dependency><!--mapper-->
<groupId>tk.mybatis</groupId>
<artifactId>mapper-spring-boot-starter</artifactId>
<version>1.2.4</version>
</dependency>
<dependency><!--pagehelper-->
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>1.2.3</version>
</dependency>
```
## 数据源配置
```java
@Configuration
public class ManagerDbConfig {
@Bean(name = "managerDataSourceProperties")
@ConfigurationProperties(prefix = "manager.datasource")
public DataSourceProperties primaryDataSourceProperties() {
return new DataSourceProperties();
}
@Bean(name = "managerDataSource")
@ConfigurationProperties(prefix = "manager.datasource")
public DataSource dataSource(@Qualifier("managerDataSourceProperties") DataSourceProperties dataSourceProperties) {
return dataSourceProperties.initializeDataSourceBuilder().build();
}
@Bean(name = "managerTransactionManager")
public DataSourceTransactionManager transactionManager(@Qualifier("managerDataSource") DataSource dataSource) {
return new DataSourceTransactionManager(dataSource);
}
@Bean(name = "managerSqlSessionFactory")
public SqlSessionFactory sqlSessionFactory(@Qualifier("managerDataSource") DataSource dataSource) throws Exception {
SqlSessionFactoryBean factoryBean = new SqlSessionFactoryBean();
factoryBean.setDataSource(dataSource);
return factoryBean.getObject();
}
@Bean(name = "managerConfigurer")
public static MapperScannerConfigurer mapperScannerConfigurer(){
MapperScannerConfigurer mapperScannerConfigurer = new MapperScannerConfigurer();
mapperScannerConfigurer.setBasePackage("cn.datawin.dao.mysql.manager");
Properties propertiesMapper = new Properties();
//通用mapper位置,不要和其他mapper、dao放在同一个目录
propertiesMapper.setProperty("mappers", "tk.mybatis.mapper.common.Mapper,tk.mybatis.mapper.common.special.InsertListMapper");
propertiesMapper.setProperty("notEmpty", "false");
//主键UUID回写方法执行顺序,默认AFTER,可选值为(BEFORE|AFTER)
//propertiesMapper.setProperty("ORDER","BEFORE");
mapperScannerConfigurer.setProperties(propertiesMapper);
mapperScannerConfigurer.setSqlSessionFactoryBeanName("managerSqlSessionFactory");
return mapperScannerConfigurer;
}
}
```
以上是关于markdown MySQL的常用语句的主要内容,如果未能解决你的问题,请参考以下文章