SystemEnvironmentCondition.java 771 B

12345678910111213141516171819202122
  1. package net.lab1024.smartadmin.config;
  2. import net.lab1024.smartadmin.constant.SystemEnvironmentEnum;
  3. import org.springframework.beans.factory.annotation.Value;
  4. import org.springframework.context.annotation.Condition;
  5. import org.springframework.context.annotation.ConditionContext;
  6. import org.springframework.core.type.AnnotatedTypeMetadata;
  7. /**
  8. * 是否是正式环境
  9. *
  10. * @author listen
  11. * @date 2019/08/27 08:56
  12. */
  13. public class SystemEnvironmentCondition implements Condition {
  14. @Value("${spring.profiles.active}")
  15. private String systemEnvironment;
  16. @Override
  17. public boolean matches(ConditionContext conditionContext, AnnotatedTypeMetadata annotatedTypeMetadata) {
  18. return ! SystemEnvironmentEnum.PROD.equalsValue(systemEnvironment);
  19. }
  20. }