- pom依赖
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>1.1.10</version>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-alibaba-seata</artifactId>
<version>2.1.0.RELEASE</version>
</dependency>
- 数据源配置
@Configuration
@Slf4j
public class DataSourceConfiguration {
@Autowired(required = true)
private DataSourceProperties dataSourceProperties;
private DataSourceProxy dataSourceProxy;
@Bean(name = "dataSource")
@Primary
public DataSource druidDataSource() {
DruidDataSource druidDataSource = new DruidDataSource();
log.info("dataSourceProperties.getUrl():{}", dataSourceProperties.getUrl());
druidDataSource.setUrl(dataSourceProperties.getUrl());
druidDataSource.setUsername(dataSourceProperties.getUsername());
druidDataSource.setPassword(dataSourceProperties.getPassword()