import static org.assertj.core.api.Assertions.assertThat;

import java.util.List;

import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.Resource;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;

@SpringJUnitConfig
public class ResourcesInjectionByFieldTests {

    @Value("classpath:application.yaml")
    private Resource[] resourcesArray;

    @Value("classpath:application.yaml")
        // @Value("classpath*:application.yaml") will works with 6.1
    private List<Resource> resourcesList;

    @Test
    void test() {
        assertThat(resourcesArray).isNotEmpty();
        assertThat(resourcesList).isNotEmpty();
    }

}

This test case failed after upgrading spring framework from 6.0 to 6.1, I believe it introduced by https://github.com/spring-projects/spring-framework/commit/84b3335e711bee38efdf6518e72d0ec441704fce which fixed https://github.com/spring-projects/spring-framework/issues/24845. It's possible that this will fix a spring boot regression.

15:51:49.983 [main] INFO org.springframework.test.context.support.AnnotationConfigContextLoaderUtils -- Could not detect default configuration classes for test class [com.example.demo.ResourcesInjectionByFieldTests]: ResourcesInjectionByFieldTests does not declare any static, non-private, non-final, nested classes annotated with @Configuration.
15:51:50.141 [main] ERROR org.springframework.test.context.TestContextManager -- Caught exception while allowing TestExecutionListener [org.springframework.test.context.support.DependencyInjectionTestExecutionListener] to prepare test instance [com.example.demo.ResourcesInjectionByFieldTests@737a135b]
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'com.example.demo.ResourcesInjectionByFieldTests': Unsatisfied dependency expressed through field 'resourcesList': Failed to convert value of type 'java.lang.String' to required type 'java.util.List'; Cannot convert value of type 'java.lang.String' to required type 'java.util.List': PropertyEditor [org.springframework.core.io.support.ResourceArrayPropertyEditor] returned inappropriate value of type 'org.springframework.core.io.ClassPathResource'
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:772)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:752)
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:145)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:493)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1420)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireBeanProperties(AbstractAutowireCapableBeanFactory.java:397)
    at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:142)
    at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:97)
    at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:247)
    at org.springframework.test.context.junit.jupiter.SpringExtension.postProcessTestInstance(SpringExtension.java:163)
...
Caused by: org.springframework.beans.TypeMismatchException: Failed to convert value of type 'java.lang.String' to required type 'java.util.List'; Cannot convert value of type 'java.lang.String' to required type 'java.util.List': PropertyEditor [org.springframework.core.io.support.ResourceArrayPropertyEditor] returned inappropriate value of type 'org.springframework.core.io.ClassPathResource'
    at org.springframework.beans.TypeConverterSupport.convertIfNecessary(TypeConverterSupport.java:87)
    at org.springframework.beans.TypeConverterSupport.convertIfNecessary(TypeConverterSupport.java:71)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1379)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1348)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:769)
    ... 76 common frames omitted
Caused by: java.lang.IllegalArgumentException: Cannot convert value of type 'java.lang.String' to required type 'java.util.List': PropertyEditor [org.springframework.core.io.support.ResourceArrayPropertyEditor] returned inappropriate value of type 'org.springframework.core.io.ClassPathResource'
    at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:268)
    at org.springframework.beans.TypeConverterSupport.convertIfNecessary(TypeConverterSupport.java:80)
    ... 80 common frames omitted

Comment From: jhoeller

Superseded by PR #31699.