顯示具有 beans 標籤的文章。 顯示所有文章
顯示具有 beans 標籤的文章。 顯示所有文章

2017年12月24日 星期日

Java Spring - 透過pointcut選擇join points


  • 透過pointcut選擇join points
    • advice及pointcut是aspect的最基本元素
    • 在Spring AOP中,要使用AspectJ的pointcut expression language定義pointcut
    • Spring僅支援AspectJ pointcut designator的子集,如下
      • arg()
      • @args()
      • execution()
      • this()
      • target
      • @target()
      • within()
      • @within()
      • @annotation

2017年12月21日 星期四

Java Spring - Configuring profile beans


  • 在開發環境中,遷移是一個挑戰(比如Dev->QA, QA->Prod)
    • 假設有個DB config,在Dev上可能使用的是EmbeddedDatabaseBuilder
    • @Bean(destroyMethod="shutdown")
      public DataSource dataSource() {
          return new EmbeddedDatabaseBuilder()
             .addScript("classpath:schema.sql") //schema會定義在schema.sql中
             .addScript("classpath:test-data.sql")//data使用test-data.sql載入
             .build();
      }