Commit 8d1cecdd authored by 张永's avatar 张永

升个版本号

parent 5d113dea
Pipeline #162 canceled with stages
package com.egolm.shop.config; package com.egolm.shop.config;
import javax.sql.DataSource; import javax.sql.DataSource;
import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder; import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary; import org.springframework.context.annotation.Primary;
import org.springframework.jdbc.datasource.DataSourceTransactionManager; import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.transaction.PlatformTransactionManager; import org.springframework.transaction.PlatformTransactionManager;
import com.alibaba.druid.pool.DruidDataSource; import com.alibaba.druid.pool.DruidDataSource;
import com.egolm.common.jdbc.JdbcTemplate; import com.egolm.common.jdbc.JdbcTemplate;
import com.egolm.common.jdbc.dialect.MySqlDialect; import com.egolm.common.jdbc.dialect.MySqlDialect;
@Configuration @Configuration
public class DataSourceConfig { public class DataSourceConfig {
@Bean @Bean
@Primary @Primary
@ConfigurationProperties(prefix = "spring.datasource") @ConfigurationProperties(prefix = "spring.datasource")
public DataSource getDataSource() { public DataSource getDataSource() {
return DataSourceBuilder.create().type(DruidDataSource.class).build(); return DataSourceBuilder.create().type(DruidDataSource.class).build();
} }
@Bean @Bean
@Primary @Primary
public PlatformTransactionManager getTransactionManager(DataSource dataSource) { public PlatformTransactionManager getTransactionManager(DataSource dataSource) {
return new DataSourceTransactionManager(dataSource); return new DataSourceTransactionManager(dataSource);
} }
@Bean @Bean
@Primary @Primary
public JdbcTemplate getJdbcTemplate(DataSource dataSource) { public JdbcTemplate getJdbcTemplate(DataSource dataSource) {
JdbcTemplate jdbcTemplate = new JdbcTemplate(); JdbcTemplate jdbcTemplate = new JdbcTemplate();
jdbcTemplate.setDataSource(dataSource); jdbcTemplate.setDataSource(dataSource);
jdbcTemplate.setDialect(new MySqlDialect()); jdbcTemplate.setDialect(new MySqlDialect());
jdbcTemplate.setSql_level(3); jdbcTemplate.setSql_level(3);
return jdbcTemplate; return jdbcTemplate;
} }
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment