annotate spring-boot-playground/src/main/java/de/comline/spring/application/AutoConfiguredApplication.java @ 6:d57d0c6a841b

Einbau von liquibase zum Erzeugen des Schemas
author Dirk Olmes <dirk.olmes@codedo.de>
date Thu, 13 Aug 2020 16:18:20 +0200
parents 92d52e4ac567
children 0c3494137a82
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
92d52e4ac567 JPA hinzugefuegt.
Dirk Olmes <dirk.olmes@codedo.de>
parents: 3
diff changeset
7 import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
92d52e4ac567 JPA hinzugefuegt.
Dirk Olmes <dirk.olmes@codedo.de>
parents: 3
diff changeset
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
92d52e4ac567 JPA hinzugefuegt.
Dirk Olmes <dirk.olmes@codedo.de>
parents: 3
diff changeset
11 import org.springframework.context.annotation.ComponentScan;
92d52e4ac567 JPA hinzugefuegt.
Dirk Olmes <dirk.olmes@codedo.de>
parents: 3
diff changeset
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
92d52e4ac567 JPA hinzugefuegt.
Dirk Olmes <dirk.olmes@codedo.de>
parents: 3
diff changeset
14 @ComponentScan(basePackages = {
92d52e4ac567 JPA hinzugefuegt.
Dirk Olmes <dirk.olmes@codedo.de>
parents: 3
diff changeset
15 "de.comline.spring.controller",
92d52e4ac567 JPA hinzugefuegt.
Dirk Olmes <dirk.olmes@codedo.de>
parents: 3
diff changeset
16 "de.comline.spring.service"
92d52e4ac567 JPA hinzugefuegt.
Dirk Olmes <dirk.olmes@codedo.de>
parents: 3
diff changeset
17 })
92d52e4ac567 JPA hinzugefuegt.
Dirk Olmes <dirk.olmes@codedo.de>
parents: 3
diff changeset
18 @EnableAutoConfiguration
92d52e4ac567 JPA hinzugefuegt.
Dirk Olmes <dirk.olmes@codedo.de>
parents: 3
diff changeset
19 @EnableJpaRepositories("de.comline.spring.repository")
92d52e4ac567 JPA hinzugefuegt.
Dirk Olmes <dirk.olmes@codedo.de>
parents: 3
diff changeset
20 @EntityScan("de.comline.spring.entity")
92d52e4ac567 JPA hinzugefuegt.
Dirk Olmes <dirk.olmes@codedo.de>
parents: 3
diff changeset
21 public class AutoConfiguredApplication {
1
60afb461bf6c Import des Spring boot playground
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff changeset
22 public static void main(String[] args) {
4
92d52e4ac567 JPA hinzugefuegt.
Dirk Olmes <dirk.olmes@codedo.de>
parents: 3
diff changeset
23 SpringApplication.run(AutoConfiguredApplication.class, args);
1
60afb461bf6c Import des Spring boot playground
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff changeset
24 }
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 @Bean
60afb461bf6c Import des Spring boot playground
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff changeset
27 public CommandLineRunner commandLineRunner(ApplicationContext ctx) {
60afb461bf6c Import des Spring boot playground
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff changeset
28 return args -> {
60afb461bf6c Import des Spring boot playground
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff changeset
29 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
30
60afb461bf6c Import des Spring boot playground
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff changeset
31 String[] beanNames = ctx.getBeanDefinitionNames();
60afb461bf6c Import des Spring boot playground
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff changeset
32 Arrays.sort(beanNames);
60afb461bf6c Import des Spring boot playground
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff changeset
33 for (String beanName : beanNames) {
60afb461bf6c Import des Spring boot playground
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff changeset
34 System.out.println(beanName);
60afb461bf6c Import des Spring boot playground
Dirk Olmes <dirk.olmes@codedo.de>
parents:
diff changeset
35 }
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 }