view spring-boot-playground/src/main/java/de/comline/spring/application/AutoConfiguredApplication.java @ 4:92d52e4ac567

JPA hinzugefuegt.
author Dirk Olmes <dirk.olmes@codedo.de>
date Thu, 13 Aug 2020 15:31:38 +0200
parents spring-boot-playground/src/main/java/de/comline/spring/application/Application.java@b4221c1389af
children 0c3494137a82
line wrap: on
line source

package de.comline.spring.application;

import java.util.Arrays;

import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;

@ComponentScan(basePackages = {
	"de.comline.spring.controller",
	"de.comline.spring.service"
})
@EnableAutoConfiguration
@EnableJpaRepositories("de.comline.spring.repository")
@EntityScan("de.comline.spring.entity")
public class AutoConfiguredApplication {
	public static void main(String[] args) {
		SpringApplication.run(AutoConfiguredApplication.class, args);
	}

	@Bean
	public CommandLineRunner commandLineRunner(ApplicationContext ctx) {
		return args -> {
			System.out.println("Let's inspect the beans provided by Spring Boot:");

			String[] beanNames = ctx.getBeanDefinitionNames();
			Arrays.sort(beanNames);
			for (String beanName : beanNames) {
				System.out.println(beanName);
			}
		};
	}
}