Mercurial > hg > SpringPlayground
comparison spring-boot-playground/src/main/java/de/comline/spring/application/Application.java @ 1:60afb461bf6c
Import des Spring boot playground
author | Dirk Olmes <dirk.olmes@codedo.de> |
---|---|
date | Tue, 11 Aug 2020 16:08:16 +0200 |
parents | |
children | 856e646efa17 |
comparison
equal
deleted
inserted
replaced
0:64e2ebad3366 | 1:60afb461bf6c |
---|---|
1 package de.comline.spring.application; | |
2 | |
3 import java.util.Arrays; | |
4 | |
5 import org.springframework.boot.CommandLineRunner; | |
6 import org.springframework.boot.SpringApplication; | |
7 import org.springframework.boot.autoconfigure.http.HttpMessageConvertersAutoConfiguration; | |
8 import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration; | |
9 import org.springframework.boot.autoconfigure.web.servlet.DispatcherServletAutoConfiguration; | |
10 import org.springframework.boot.autoconfigure.web.servlet.ServletWebServerFactoryAutoConfiguration; | |
11 import org.springframework.context.ApplicationContext; | |
12 import org.springframework.context.annotation.Bean; | |
13 import org.springframework.context.annotation.Configuration; | |
14 import org.springframework.context.annotation.Import; | |
15 | |
16 import de.comline.spring.application.Application.CustomConfig; | |
17 import de.comline.spring.controller.CustomLogicController; | |
18 import de.comline.spring.controller.HelloController; | |
19 import de.comline.spring.service.CustomLogicService; | |
20 | |
21 //@SpringBootApplication | |
22 | |
23 //@ComponentScan(basePackages = "de.comline.spring.controller,de.comline.spring.service") | |
24 //@EnableAutoConfiguration | |
25 | |
26 @Import(CustomConfig.class) | |
27 public class Application { | |
28 public static void main(String[] args) { | |
29 SpringApplication.run(Application.class, args); | |
30 } | |
31 | |
32 @Bean | |
33 public CommandLineRunner commandLineRunner(ApplicationContext ctx) { | |
34 return args -> { | |
35 System.out.println("Let's inspect the beans provided by Spring Boot:"); | |
36 | |
37 String[] beanNames = ctx.getBeanDefinitionNames(); | |
38 Arrays.sort(beanNames); | |
39 for (String beanName : beanNames) { | |
40 System.out.println(beanName); | |
41 } | |
42 }; | |
43 } | |
44 | |
45 @Configuration | |
46 // scheint hier nicht zu funktionieren: | |
47 // @ComponentScan(basePackages = "de.comline.spring.controller,de.comline.spring.service") | |
48 | |
49 // ServletWebServerFactoryAutoConfiguration for bringing up the embedded tomcat | |
50 // DispatcherServletAutoConfiguration for detecting the REST controllers | |
51 // @formatter:off | |
52 @Import({ | |
53 ServletWebServerFactoryAutoConfiguration.class, | |
54 DispatcherServletAutoConfiguration.class, | |
55 JacksonAutoConfiguration.class, | |
56 HttpMessageConvertersAutoConfiguration.class, | |
57 // HttpEncodingAutoConfiguration.class, | |
58 // CodecsAutoConfiguration.class, | |
59 | |
60 HelloController.class, | |
61 CustomLogicController.class, | |
62 CustomLogicService.class | |
63 }) | |
64 // @formatter:on | |
65 static class CustomConfig { | |
66 // no custom methods | |
67 } | |
68 } |