Reputation: 3059
I've a @SpringBootApplication
annotation in main class of my Spring Boot Application with ordinary folders structure (and @SpringBootApplication
is one level package upper then beans in other packages)
I defined some @Configuration
classes in some packages but under the test
folder.
Will @SpringBootApplication
autoconfigure it when start application?
Will @SpringBootApplication
autoconfigure it when it will be finded by @SpringBootTest
(it's also one level upper but in test
folder) when test started?
Upvotes: 2
Views: 1258
Reputation: 17460
I am not completely sure, but I would say no, @SpringBootApplication
does not scan @Configuration
classes in your test folder. What you should use instead is @TestConfiguration
and then in your @SpringBootTest
add @Import(YourTestConfiguration.class)
. Find an example below:
@TestConfiguration
public class YourTestConfiguration {
@Bean
(...)
}
@SpringBootTest
@Import(YourTestConfiguration.class)
class AppTests {
(...)
}
You can read more about this and check complete examples in the following online resources:
Upvotes: 2