Skip to content

bugfix: SeataSagaAutoConfiguration @AutoConfigureAfter fails on Spring Boot 4.x due to hardcoded old DataSourceAutoConfiguration class path #8154

Description

@zhangyan54545

Bug Report

Affected version: Seata 2.5.0, 2.x branch

Severity: High — Saga auto-configuration is completely skipped on Spring Boot 4.x

Root Cause

SeataSagaAutoConfiguration uses a hardcoded class reference in @AutoConfigureAfter:

@AutoConfigureAfter({DataSourceAutoConfiguration.class, SeataAutoConfiguration.class})

where DataSourceAutoConfiguration.class resolves to org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration at compile time.

In Spring Boot 4.x, this class has been moved to org.springframework.boot.jdbc.autoconfigure.DataSourceAutoConfiguration. The old class no longer exists, causing JVM to throw TypeNotPresentException when introspecting the meta-annotation, which silently skips the entire auto-configuration.

Symptom

Failed to introspect meta-annotation @AutoConfigureAfter on 
SeataSagaAutoConfiguration: java.lang.TypeNotPresentException: 
Type org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration not present

Fix Pattern (already used by SeataDataSourceAutoConfiguration)

SeataDataSourceAutoConfiguration already uses string-based names to avoid this:

@AutoConfigureAfter(
    value = {SeataCoreAutoConfiguration.class},
    name = "org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration")

The same approach should be applied to SeataSagaAutoConfiguration.

Expected Fix

@AutoConfigureAfter(value = {SeataAutoConfiguration.class},
    name = {"org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration",
            "org.springframework.boot.jdbc.autoconfigure.DataSourceAutoConfiguration"})

Remove the import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; line.

This fix is consistent with:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions