With a project from start.spring.io.

package com.example.demo;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import jakarta.annotation.PostConstruct;

@SpringBootApplication
public class DemoApplication {

    public static class Base {
        public Base() {
            System.err.println("Class of type " + getClass().getSimpleName() + " created");
        }

        public Base(Base[] otherBases) {
            this();
            System.err.println("This constructor should not run");
        }
    }

    @Component
    @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
    public static class Other extends Base {
    }

    @Autowired
    private ApplicationContext context;

    @PostConstruct
    public void init() {
        Base object = context.getAutowireCapableBeanFactory().createBean(Base.class);
        System.err.println("Bean factory returned bean of type " + object.getClass().getSimpleName());
    }

    public static void main(String[] args) {
        SpringApplication.run(DemoApplication.class, args);
    }

}

Expected output, as with version 6.0.4 / Spring Boot 3.0.2

Class of type Base created
Bean factory returned bean of type Base

Actual output with 6.0.5 / Spring Boot 3.0.3

Class of type Other created
Class of type Base created
This constructor should not run
Bean factory returned bean of type Base

Comment From: Artur-

Probably related to #29855 by @jhoeller

Comment From: Artur-

Just to be clear: for us the main problem is that an extra bean is created, not that the wrong constructor is used (although I am sure the latter will be a problem also..)

Comment From: jhoeller

Understood. From the framework perspective, the root of the problem is the selection of a different constructor in the case of multiple public constructors, hence the change of title.

I've applied a narrower algorithm now that selects a Kotlin primary / single public / single non-public constructor candidate, analogous to our constructor resolution convention for data/record classes, in addition to the default constructor. So in ambiguous scenarios with multiple constructors at the same level, we prefer the default constructor now rather than select by autowiring ability, while at the same time picking the obvious preferred constructor in other scenarios (analogous to AutowiredAnnotationBeanPostProcessor, just without the differentiation of annotated versus non-annotated constructors).

This will be included in the 6.0.6 release tonight, hopefully addressing the common regression while also keeping the intention of #29855. In 6.1, we will eventually deprecate the overloaded createBean variants and phase out autowiring modes such as AUTOWIRE_CONSTRUCTOR completely (except for XML definitions), consistently relying on constructor selection conventions for Class-based bean definitions outside of the annotation-based programming model as well.

Comment From: Artur-

Thanks, latest 6.0-SNAPSHOT seems to work again