package com.cool.store;

import com.zaxxer.hikari.HikariDataSource;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Primary;
import org.springframework.scheduling.annotation.EnableAsync;
import tk.mybatis.spring.annotation.MapperScan;

import javax.sql.DataSource;

/**
 * @author zhangchenbiao
 * @FileName: PartnerCWebApplication
 * @Description: C端web层
 * @date 2023-05-17 11:28
 */
@SpringBootApplication
@EnableAsync
@MapperScan("com.cool.store.mapper")
public class PartnerWebApplication {

    public static void main(String[] args) {
        SpringApplication.run(PartnerWebApplication.class, args);
    }

    @Bean
    @Primary
    @ConfigurationProperties("default.datasource")
    public DataSourceProperties defaultDataSourceProperties() {
        return new DataSourceProperties();
    }

    @Bean
    @ConfigurationProperties("spring.datasource.hikari")
    public DataSource defaultDataSource() {
        return defaultDataSourceProperties().initializeDataSourceBuilder().type(HikariDataSource.class).build();
    }

}
