Boot.java 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. package com.malk.zhixingtongde;
  2. import com.querydsl.jpa.impl.JPAQueryFactory;
  3. import org.springframework.boot.SpringApplication;
  4. import org.springframework.boot.autoconfigure.SpringBootApplication;
  5. import org.springframework.context.annotation.Bean;
  6. import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
  7. import javax.persistence.EntityManager;
  8. /**
  9. * corp项目: 扫描公共模块
  10. * -
  11. * 若是无需数据库模块, 配置无效地址也可启动, 引入mjava不支持直接 @SpringBootApplication(exclude = DataSourceAutoConfiguration.class) 配置
  12. * 需要配置 jpa.hibernate.ddl-auto 为 none. 标识对表没有任何操作. 若不设置为 none, flyway.enabled 配置会无效, 在没有数库连接情况下程序无法启动
  13. */
  14. @EnableJpaAuditing
  15. @SpringBootApplication(scanBasePackages = {"com.malk"})
  16. public class Boot {
  17. public static void main(String... args) {
  18. try {
  19. SpringApplication.run(Boot.class, args);
  20. }catch (Exception e){
  21. e.printStackTrace();
  22. }
  23. }
  24. /**
  25. * 让Spring管理JPAQueryFactory [不使用Qualifier详见mjava-Boot]
  26. */
  27. @Bean
  28. public JPAQueryFactory jpaQueryFactory(EntityManager entityManager) {
  29. return new JPAQueryFactory(entityManager);
  30. }
  31. }