DataSource.java 569 B

12345678910111213141516171819202122
  1. package com.coffee.common.annotation;
  2. import com.coffee.common.enums.DataSourceTypeEnum;
  3. import java.lang.annotation.*;
  4. /**
  5. * 自定义多数据源切换注解
  6. * 优先级:先方法,后类,如果方法覆盖了类上的数据源类型,以方法的为准,否则以类上的为准
  7. *
  8. * @author Kevin
  9. */
  10. @Target({ElementType.METHOD, ElementType.TYPE})
  11. @Retention(RetentionPolicy.RUNTIME)
  12. @Documented
  13. @Inherited
  14. public @interface DataSource {
  15. /**
  16. * 切换数据源名称
  17. */
  18. DataSourceTypeEnum value() default DataSourceTypeEnum.MASTER;
  19. }