Skip to content

Fix bug about no bean found of type feign.codec.Encoder in Spring Boot 4#49457

Open
Copilot wants to merge 5 commits into
mainfrom
copilot/fix-cosmos-openfeign-issue
Open

Fix bug about no bean found of type feign.codec.Encoder in Spring Boot 4#49457
Copilot wants to merge 5 commits into
mainfrom
copilot/fix-cosmos-openfeign-issue

Conversation

Copilot AI commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Problem

Using azure-spring-data-cosmos with spring-cloud-starter-openfeign:5.0.1 on Spring Boot 4 fails at startup with java.lang.IllegalStateException: No bean found of type interface feign.codec.Encoder.

Root cause: OpenFeign 5.0.1's FeignClientsConfiguration has two encoder bean paths:

  • SpringEncoder — guarded by @ConditionalOnMissingClass("org.springframework.data.domain.Pageable")skipped because azure-spring-data-cosmos transitively pulls in spring-data-commons which contains Pageable
  • PageableSpringEncoder (in SpringDataConfiguration) — guarded by @ConditionalOnClass({ Pageable.class, DataWebProperties.class })skipped because DataWebProperties moved from spring-data-commons to spring-boot-data-commons in Spring Boot 4, which was not on the classpath

Neither path fires → no Encoder bean → startup failure.

Changes

  • azure-spring-data-cosmos/pom.xml: Add spring-boot-data-commons:4.0.6 as a compile dependency. This puts DataWebProperties on the classpath, enabling OpenFeign's SpringDataConfiguration conditional to pass and PageableSpringEncoder to be registered.
  • module-info.java: Add requires spring.boot.data.commons.
  • eng/versioning/external_dependencies.txt: Register springboot4_org.springframework.boot:spring-boot-data-commons;4.0.6.
  • CHANGELOG.md: Document the fix.

…bility

Co-authored-by: rujche <171773178+rujche@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix azure-spring-data-cosmos fails with OpenFeign on Spring Boot 4 fix(azure-spring-data-cosmos): add spring-boot-data-commons to fix OpenFeign encoder failure on Spring Boot 4 Jun 11, 2026
Copilot AI requested a review from rujche June 11, 2026 02:09
@rujche rujche changed the title fix(azure-spring-data-cosmos): add spring-boot-data-commons to fix OpenFeign encoder failure on Spring Boot 4 Fix bug about no bean found of type feign.codec.Encoder in Spring Boot 4 Jun 11, 2026
@rujche rujche added bug This issue requires a change to an existing behavior in the product in order to be resolved. azure-spring-cosmos Spring cosmos related issues. labels Jun 11, 2026
@rujche rujche moved this from Todo to In Progress in Spring Cloud Azure Jun 11, 2026
@rujche rujche added this to the 2026-07 milestone Jun 11, 2026
Adds OpenFeignEncoderBeanRegistrationUnitTest which loads OpenFeign's FeignClientsConfiguration on the azure-spring-data-cosmos classpath and asserts a feign.codec.Encoder bean (PageableSpringEncoder) is registered. Without the spring-boot-data-commons dependency the bean is missing, reproducing issue #49441.
@rujche rujche marked this pull request as ready for review June 11, 2026 08:46
Copilot AI review requested due to automatic review settings June 11, 2026 08:46
@rujche

rujche commented Jun 11, 2026

Copy link
Copy Markdown
Member

/azp java - spring - tests

@azure-pipelines

Copy link
Copy Markdown
Command 'java' is not supported by Azure Pipelines.

Supported commands
  • help:
    • Get descriptions, examples and documentation about supported commands
    • Example: help "command_name"
  • list:
    • List all pipelines for this repository using a comment.
    • Example: "list"
  • run:
    • Run all pipelines or specific pipelines for this repository using a comment. Use this command by itself to trigger all related pipelines, or specify specific pipelines to run.
    • Example: "run" or "run pipeline_name, pipeline_name, pipeline_name"
  • where:
    • Report back the Azure DevOps orgs that are related to this repository and org
    • Example: "where"

See additional documentation.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses a Spring Boot 4 + Spring Cloud OpenFeign 5.0.1 startup failure when azure-spring-data-cosmos is on the classpath, where OpenFeign doesn’t register any feign.codec.Encoder due to conditional configuration not matching after DataWebProperties moved to spring-boot-data-commons.

Changes:

  • Add org.springframework.boot:spring-boot-data-commons:4.0.6 as a main dependency (and JPMS requires) so OpenFeign’s @ConditionalOnClass({ Pageable.class, DataWebProperties.class }) path can activate.
  • Add a focused regression test that loads FeignClientsConfiguration and asserts an Encoder bean is present (and is PageableSpringEncoder).
  • Register the new external dependencies and document the fix in the module changelog.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/config/OpenFeignEncoderBeanRegistrationUnitTest.java Adds regression coverage ensuring OpenFeign registers an Encoder on the azure-spring-data-cosmos classpath under Spring Boot 4.
sdk/spring/azure-spring-data-cosmos/src/main/java/module-info.java Adds the JPMS requirement for spring.boot.data.commons so the module resolves it on the module path.
sdk/spring/azure-spring-data-cosmos/pom.xml Adds spring-boot-data-commons as a main dependency and adds OpenFeign starter for the regression test; updates enforcer includes accordingly.
sdk/spring/azure-spring-data-cosmos/CHANGELOG.md Documents the bug fix in the Unreleased section.
eng/versioning/external_dependencies.txt Registers spring-boot-data-commons and spring-cloud-starter-openfeign in the external dependencies list.

Comment thread sdk/spring/azure-spring-data-cosmos/CHANGELOG.md Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.

@rujche

rujche commented Jun 12, 2026

Copy link
Copy Markdown
Member

/azp run java - spring - tests

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

azure-spring-cosmos Spring cosmos related issues. bug This issue requires a change to an existing behavior in the product in order to be resolved.

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

[BUG][Cosmos] azure-spring-data-cosmos 7.3.0 fails with OpenFeign 5.0.1 on Spring Boot 4 – No bean found of type feign.codec.Encoder

3 participants