且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Spring Boot Cloud Foundry错误中没有唯一的服务处理接口错误

更新时间:2023-09-07 07:54:34

如果包含 spring-boot-starter-cloud-connectors 作为依赖项,然后Spring Cloud Connectors将尝试创建连接数据库所需的 java.sql.DataSource bean。连接器通过查找具有服务绑定来实现此目的= http://cloud.spring.io/spring-cloud-connectors/spring-cloud-cloud-foundry-connector.html#_postgresql rel = nofollow noreferrer>某些特征。 找不到唯一的服务匹配接口javax.sql.DataSource 消息表示连接器找不到适当类型的服务绑定。

If you include spring-boot-starter-cloud-connectors as a dependency, then Spring Cloud Connectors will attempt to create the java.sql.DataSource bean necessary to connect to the database. Connectors does this by looking for a service binding that has certain characteristics. The No unique service matching interface javax.sql.DataSource found message means that Connectors couldn't find a service binding of the appropriate type.

如果要在该示例应用程序中使用连接器,则需要创建用户提供的服务实例,其中包含Postgres连接的详细信息,并将该服务实例绑定到应用程序。

If you want to use Connectors as in that sample app then you will need to create a user-provided service instance with the details of the Postgres connection and bind that service instance to the app.

或者,您可以删除 spring-boot-starter-cloud-connectors 依赖性,而使用 spring.datasource配置数据库连接。 application.yml 中的属性。

Alternatively, you could remove the spring-boot-starter-cloud-connectors dependency and instead configure the database connection using spring.datasource properties in application.yml.

这些选项在博客文章