Skip to content

Devtools main method search algorithm can find incorrect main method #35214

@sivaprasadreddy

Description

@sivaprasadreddy

I am using spring-boot-3.1.0-SNAPSHOT with Spring Data JPA, Postgres, Testcontainers.
For local development, I have created TestcontainersConfiguration.java and TestApplication.java under src/test/java as follows:

@TestConfiguration(proxyBeanMethods = false) public class TestcontainersConfiguration { @Bean @ServiceConnection public PostgreSQLContainer<?> postgreSQLContainer() { return new PostgreSQLContainer<>("postgres:15.2-alpine"); } } 
public class TestApplication { public static void main(String[] args) { SpringApplication .from(Application::main) .with(TestcontainersConfiguration.class) .run(args); } } 

When I run TestApplication.java from IDE then Testcontainers is starting the Postgres database and application is working fine.

Problem:
But, if I add spring-boot-devtools dependency and run TestApplication.java then Testcontainers integration is stopped working. ie, Postgres container is not being started and application startup is failing.

Reproducer: https://github.com/sivaprasadreddy/spring-boot-testcontainers-devmode

In pom.xml uncomment spring-boot-devtools dependency and run to reproduce the problem.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions