Boot.java 1.2 KB

1234567891011121314151617181920212223242526272829303132
  1. package com.malk.pake;
  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. SpringApplication.run(Boot.class, args);
  19. }
  20. /**
  21. * 让Spring管理JPAQueryFactory [不使用Qualifier详见mjava-Boot]
  22. */
  23. @Bean
  24. public JPAQueryFactory jpaQueryFactory(EntityManager entityManager) {
  25. return new JPAQueryFactory(entityManager);
  26. }
  27. }