package com.ym.mec.workfow;

import javax.sql.DataSource;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;

import com.spring4all.swagger.EnableSwagger2Doc;

@SpringBootApplication
@EnableDiscoveryClient
@EnableFeignClients("com.ym.mec")
@MapperScan("com.ym.mec.workflow.dal.dao")
@ComponentScan(basePackages = { "com.ym.mec", "org.snaker.engine" })
@Configuration
@EnableSwagger2Doc
public class WorkflowApplication {

	@Autowired
	private DataSource dataSource;
	
	public static void main(String[] args) {
		SpringApplication.run(WorkflowApplication.class, args);
	}

	@Bean
	public DataSourceTransactionManager transactionManager(DataSourceProperties properties) {
		DataSourceTransactionManager transactionManager = new DataSourceTransactionManager(this.dataSource);
		return transactionManager;
	}
}
