Springboot项目中用多套配置文件可以动态的切换数据源。事例如下


SpringBoot动态多数据源的配置
pom.xml的依赖为:

<profiles>
<profile>
<id>development</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<project.profile>development</project.profile>
</properties>
</profile>
<profile>
<id>production</id>
<properties>
<project.profile>production</project.profile>
</properties>
</profile>
<profile>
<id>test</id>
<properties>
<project.profile>test</project.profile>
</properties>
</profile>
<profile>
<id>zztest</id>
<properties>
<project.profile>zztest</project.profile>
</properties>
</profile>
</profiles>
这样配置之后即可根据环境动态切换配置文件(包含数据源)

相关文章:

  • 2022-02-08
  • 2022-01-16
  • 2021-11-19
  • 2021-06-21
  • 2021-07-04
猜你喜欢
  • 2021-12-28
  • 2021-07-24
  • 2022-12-23
  • 2021-12-22
  • 2022-01-16
  • 2021-11-30
相关资源
相似解决方案