Mercurial > hg > SpringPlayground
annotate spring-boot-playground/src/main/java/de/comline/spring/application/AutoConfiguredApplication.java @ 10:29e2e914c4cd
Verschieben der Datenbank ins target Verzeichnis, damit das Home Verzeichnis nicht vollgemuellt wird
author | Dirk Olmes <dirk.olmes@codedo.de> |
---|---|
date | Thu, 13 Aug 2020 17:17:45 +0200 |
parents | 0c3494137a82 |
children |
rev | line source |
---|---|
1
60afb461bf6c
Import des Spring boot playground
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff
changeset
|
1 package de.comline.spring.application; |
60afb461bf6c
Import des Spring boot playground
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff
changeset
|
2 |
60afb461bf6c
Import des Spring boot playground
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff
changeset
|
3 import java.util.Arrays; |
60afb461bf6c
Import des Spring boot playground
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff
changeset
|
4 |
60afb461bf6c
Import des Spring boot playground
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff
changeset
|
5 import org.springframework.boot.CommandLineRunner; |
60afb461bf6c
Import des Spring boot playground
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff
changeset
|
6 import org.springframework.boot.SpringApplication; |
4 | 7 import org.springframework.boot.autoconfigure.EnableAutoConfiguration; |
8 import org.springframework.boot.autoconfigure.domain.EntityScan; | |
1
60afb461bf6c
Import des Spring boot playground
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff
changeset
|
9 import org.springframework.context.ApplicationContext; |
60afb461bf6c
Import des Spring boot playground
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff
changeset
|
10 import org.springframework.context.annotation.Bean; |
4 | 11 import org.springframework.context.annotation.ComponentScan; |
12 import org.springframework.data.jpa.repository.config.EnableJpaRepositories; | |
1
60afb461bf6c
Import des Spring boot playground
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff
changeset
|
13 |
4 | 14 @ComponentScan(basePackages = { |
7
0c3494137a82
Starte eine H2 web console auf port 8081 fuer besseres DB debugging.
Dirk Olmes <dirk.olmes@codedo.de>
parents:
4
diff
changeset
|
15 "de.comline.spring.config", |
4 | 16 "de.comline.spring.controller", |
17 "de.comline.spring.service" | |
18 }) | |
19 @EnableAutoConfiguration | |
20 @EnableJpaRepositories("de.comline.spring.repository") | |
21 @EntityScan("de.comline.spring.entity") | |
22 public class AutoConfiguredApplication { | |
1
60afb461bf6c
Import des Spring boot playground
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff
changeset
|
23 public static void main(String[] args) { |
4 | 24 SpringApplication.run(AutoConfiguredApplication.class, args); |
1
60afb461bf6c
Import des Spring boot playground
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff
changeset
|
25 } |
60afb461bf6c
Import des Spring boot playground
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff
changeset
|
26 |
60afb461bf6c
Import des Spring boot playground
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff
changeset
|
27 @Bean |
60afb461bf6c
Import des Spring boot playground
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff
changeset
|
28 public CommandLineRunner commandLineRunner(ApplicationContext ctx) { |
60afb461bf6c
Import des Spring boot playground
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff
changeset
|
29 return args -> { |
60afb461bf6c
Import des Spring boot playground
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff
changeset
|
30 System.out.println("Let's inspect the beans provided by Spring Boot:"); |
60afb461bf6c
Import des Spring boot playground
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff
changeset
|
31 |
60afb461bf6c
Import des Spring boot playground
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff
changeset
|
32 String[] beanNames = ctx.getBeanDefinitionNames(); |
60afb461bf6c
Import des Spring boot playground
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff
changeset
|
33 Arrays.sort(beanNames); |
60afb461bf6c
Import des Spring boot playground
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff
changeset
|
34 for (String beanName : beanNames) { |
60afb461bf6c
Import des Spring boot playground
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff
changeset
|
35 System.out.println(beanName); |
60afb461bf6c
Import des Spring boot playground
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff
changeset
|
36 } |
60afb461bf6c
Import des Spring boot playground
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff
changeset
|
37 }; |
60afb461bf6c
Import des Spring boot playground
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff
changeset
|
38 } |
60afb461bf6c
Import des Spring boot playground
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff
changeset
|
39 } |