Skip to content

Commit

Permalink
up
Browse files Browse the repository at this point in the history
  • Loading branch information
huayanYu committed Jul 16, 2023
1 parent 6509a43 commit cd70fba
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 6 deletions.
10 changes: 8 additions & 2 deletions springboot3-sample/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<spring-boot-dependencies.version>3.1.0</spring-boot-dependencies.version>
<spring-boot-dependencies.version>3.1.1</spring-boot-dependencies.version>
</properties>

<dependencies>
Expand All @@ -34,13 +34,19 @@
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>dynamic-datasource-spring-boot-starter</artifactId>
<artifactId>dynamic-datasource-spring-boot3-starter</artifactId>
<version>4.1.1</version>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>3.0.2</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-3-starter</artifactId>
<version>1.2.18</version>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
*/
package com.baomidou.sample.boot3;

import com.alibaba.druid.spring.boot3.autoconfigure.DruidDataSourceAutoConfigure;
import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@Slf4j
@SpringBootApplication
@SpringBootApplication(exclude = DruidDataSourceAutoConfigure.class)
@MapperScan("com.baomidou.sample.boot3.mapper")
public class SpringBoot3Application {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
package com.baomidou.sample.boot3.service.impl;


import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.dynamic.datasource.annotation.Slave;
import com.baomidou.sample.boot3.entity.User;
import com.baomidou.sample.boot3.mapper.UserMapper;
import com.baomidou.sample.boot3.service.UserService;
Expand All @@ -36,7 +36,7 @@ public List<User> selectMasterUsers() {
return userMapper.selectUsers();
}

@DS("#header.ds")
@Slave
@Override
public List<User> selectSlaveUsers() {
return userMapper.selectUsers();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
com.alibaba.druid.spring.boot3.autoconfigure.DruidDataSourceAutoConfigure
5 changes: 5 additions & 0 deletions springboot3-sample/src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
spring:
datasource:
druid:
stat-view-servlet:
enabled: true
login-username: admin
login-password: 123456
dynamic:
datasource:
master:
Expand Down

0 comments on commit cd70fba

Please sign in to comment.