Description
I have a simple ConfigurationProperties
class that binds a String property to a Path
object:
@Component
@ConfigurationProperties("app")
@Getter
@Setter
public class AppConfigurationProperties {
private Path somePath;
}
Then I define app.somePath=C:\\temp
within application.properties. This works when running the application, but a simple Test that loads the context throws:
com.example.demo.DemoApplicationTests > contextLoads() FAILED
java.lang.IllegalStateException
Caused by: org.springframework.boot.context.properties.ConfigurationPropertiesBindException
Caused by: org.springframework.boot.context.properties.bind.BindException
Caused by: org.springframework.core.convert.ConverterNotFoundException
The test class is most simple:
@SpringBootTest
public class DemoApplicationTests {
@Test
public void contextLoads() {
}
}
I created a project with the most recent Spring-Boot version (2.1.8.RELEASE) with Initializr (Gradle build with Spring Web as only dependency) to replicate the problem in isolation. It can be found here. I run the project on Windows 10.
I found out that the test passes, if there are no backslashes in the property value. Furthermore, it passes if I don't use org.springframework.boot:spring-boot-starter-web
but org.springframework.boot:spring-boot-starter
as dependency. (The test project does not require web, but the actual project does.)