简体   繁体   English

如何在 Spring Cloud Config 中定义共享数据源

[英]How to define a Shared DataSource in Spring Cloud Config

Would it be possible to set up a DataSource using Spring Cloud in which open JDBC connections could be injected into all of my Spring Boot applications?是否可以使用 Spring Cloud 设置一个数据源,其中开放的 JDBC 连接可以注入到我的所有 Spring Boot 应用程序中?

Something kind of like a JNDI server lookup?有点像 JNDI 服务器查找? If so, can someone provide some examples or a description on how to use this type of configuration?如果是这样,有人可以提供一些示例或描述如何使用这种类型的配置吗?

You could use a Spring Cloud bootstrap configuration to create a DataSource .可以使用 Spring Cloud 引导程序配置来创建DataSource I don't see much value in doing it that way over a normal Spring Boot autoconfiguration though.尽管如此,我认为这样做比普通的 Spring Boot 自动配置没有多大价值。 Link: http://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#boot-features-developing-auto-configuration .链接: http : //docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#boot-features-developing-auto-configuration

One solution I found out was to set all datasources info into the properties files which will supplied by Spring Cloud Config Server to applications clients.我发现的一种解决方案是将所有数据源信息设置到 Spring Cloud Config Server 将提供给应用程序客户端的属性文件中。 So the aplications clients which creates DataSources gets from remote properties those values.因此,创建数据源的应用程序客户端从远程属性获取这些值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM