AnimalSoundsApplication.java 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. package com.rf.animalSounds;
  2. import com.querydsl.jpa.impl.JPAQueryFactory;
  3. import lombok.extern.slf4j.Slf4j;
  4. import org.slf4j.Logger;
  5. import org.slf4j.LoggerFactory;
  6. import org.springframework.beans.factory.annotation.Autowired;
  7. import org.springframework.beans.factory.annotation.Value;
  8. import org.springframework.boot.SpringApplication;
  9. import org.springframework.boot.autoconfigure.SpringBootApplication;
  10. import org.springframework.context.annotation.Bean;
  11. import org.springframework.core.env.Environment;
  12. import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
  13. import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
  14. import org.springframework.scheduling.annotation.EnableScheduling;
  15. import org.springframework.transaction.annotation.EnableTransactionManagement;
  16. import javax.persistence.EntityManager;
  17. /**
  18. * @author zzf
  19. */
  20. @EnableJpaRepositories(basePackages = {"com.rf.animalSounds"})
  21. @SpringBootApplication(scanBasePackages = {"com.rf.animalSounds"})
  22. @EnableJpaAuditing
  23. @EnableTransactionManagement
  24. @EnableScheduling
  25. @Slf4j
  26. public class AnimalSoundsApplication {
  27. static Logger logger = LoggerFactory.getLogger(AnimalSoundsApplication.class);
  28. @Autowired
  29. static Environment environment;
  30. @Value("${spring.profiles.active}")
  31. static String profile;
  32. public static void main(String[] args) {
  33. SpringApplication.run(AnimalSoundsApplication.class, args);
  34. }
  35. /**
  36. * 让Spring管理JPAQueryFactory
  37. *
  38. * @param entityManager
  39. * @return
  40. */
  41. @Bean
  42. public JPAQueryFactory jpaQueryFactory(EntityManager entityManager) {
  43. return new JPAQueryFactory(entityManager);
  44. }
  45. }