spring-projects / spring-projects/spring-modulith
@ApplicationModuleTest not inheriting the @Import classes from Base Test
@odrotbohm is already working on this.
Since Feb 20, 2026.
- Dominant language
- Java
- Stars
- 1.2k
- Forks
- 222
- PR merge metrics
- No merged PRs in 30d
Description
Until Spring Modulith 2.0.0 the following test setup is working fine.
@Import(TestcontainersConfiguration.class)
@AutoConfigureMockMvc
public abstract class AbstractIntegrationTest {
@Autowired
protected MockMvcTester mockMvcTester;
}
@ApplicationModuleTest(
webEnvironment = RANDOM_PORT,
mode = DIRECT_DEPENDENCIES,
extraIncludes = {"config", "users"})
class AdminBooksControllerTests extends AbstractIntegrationTest {
//tests
}
But when I upgrade to Spring Modulith 2.0.1 or 2.0.2, the TestcontainersConfiguration is not considered and failed with the following error:
WARN org.springframework.boot.web.server.servlet.context.AnnotationConfigServletWebServerApplicationContext - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'com.sivalabs.bookstore.common.TestcontainersConfiguration' available
I can work around this by simply adding @Import(TestcontainersConfiguration.class) to all the tests like AdminBooksControllerTests. But instead of duplicating the configuration, I would prefer to have it in parent base test and work as it used to in Spring Modulith 2.0.0.
PS: Reproducer repo https://github.com/sivaprasadreddy/bookstore
More context:
The TestcontainersConfiguration and AbstractIntegrationTest are in common package com.sivalabs.bookstore.common and AdminBooksControllerTests is in com.sivalabs.bookstore.admin.web package then it is failing. However, if I move TestcontainersConfiguration and AbstractIntegrationTest to the base package com.sivalabs.bookstore then its working fine.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.