Found in Spring Boot v2.4.0 (works in v2.3.x) application.properties to Map parser behavior has changed significantly, now a line following empty comment is ignored.

Example (failing)

#
property.map.key1=value1
property.map.key2=value2

Example (working):

# non-empty comment
property.map.key1=value1
property.map.key2=value2

Reproducer

ConfigTest.java

import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;

import java.util.Map;

import static org.junit.jupiter.api.Assertions.assertEquals;

@SpringBootTest(classes = ConfigTest.Property.class)
@ActiveProfiles("propertytest")
@EnableConfigurationProperties
public class ConfigTest {
    @Autowired
    private Property property;

    @Test
    public void testProperty() {
        assertEquals(2, property.getMap().size());
    }

    @ConfigurationProperties("property")
    public static class Property {
        private Map<String, String> map;

        public Map<String, String> getMap() {
            return map;
        }

        public void setMap(Map<String, String> map) {
            this.map = map;
        }
    }
}

application-propertytest.properties

#
property.map.key1=value1
property.map.key2=value2

Comment From: bclozel

This is a duplicate of #24158, which is already fixed in 2.4.1-SNAPSHOT. Thanks for the report!