Ensure CLI adds @EnableAutoConfiguration in an appropriate place
Up to now we have been treating the *first* class to be compiled as the "main" application and adding @EnableAutoConfiguration. This isn't always appropriate (e.g. if it's a test case), so now we look for an appropriate annotation before falling back to the old behaviour. In addition ensures classes with a field of type Reactor trigger the reactor auto imports. See gh-969
This commit is contained in:
19
spring-boot-cli/test-samples/integration_auto.groovy
Normal file
19
spring-boot-cli/test-samples/integration_auto.groovy
Normal file
@@ -0,0 +1,19 @@
|
||||
@SpringApplicationConfiguration(classes=Application)
|
||||
@IntegrationTest('server.port:0')
|
||||
@WebAppConfiguration
|
||||
class RestTests {
|
||||
|
||||
@Value('${local.server.port}')
|
||||
int port
|
||||
|
||||
@Test
|
||||
void testHome() {
|
||||
assertEquals('Hello', new TestRestTemplate().getForObject('http://localhost:' + port, String))
|
||||
}
|
||||
|
||||
@RestController
|
||||
static class Application {
|
||||
@RequestMapping('/')
|
||||
String hello() { 'Hello' }
|
||||
}
|
||||
}
|
||||
13
spring-boot-cli/test-samples/integration_auto_test.groovy
Normal file
13
spring-boot-cli/test-samples/integration_auto_test.groovy
Normal file
@@ -0,0 +1,13 @@
|
||||
@SpringApplicationConfiguration(classes=ReactorApplication)
|
||||
@IntegrationTest('server.port:0')
|
||||
class RestTests {
|
||||
|
||||
@Autowired
|
||||
Reactor reactor
|
||||
|
||||
@Test
|
||||
void test() {
|
||||
assertNotNull(reactor)
|
||||
}
|
||||
|
||||
}
|
||||
4
spring-boot-cli/test-samples/reactor.groovy
Normal file
4
spring-boot-cli/test-samples/reactor.groovy
Normal file
@@ -0,0 +1,4 @@
|
||||
@Configuration
|
||||
@EnableReactor
|
||||
class ReactorApplication {
|
||||
}
|
||||
Reference in New Issue
Block a user