import com.jolbox.bonecp.BoneCPDataSource;
import org.mybatis.spring.SqlSessionFactoryBean;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.*;
import org.springframework.core.env.Environment;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.transaction.annotation.EnableTransactionManagement;
@ComponentScan
@ImportResource({"classpath:spring-config.xml"})
@PropertySources({
@PropertySource("classpath:jdbc.properties"),
@PropertySource(value = "file:${IVMALL_COMMON_CONFIG_DIR}/jdbc.properties", ignoreResourceNotFound = true)
})
// 开启注解事务 == <tx:annotation-driven/>
@EnableTransactionManagement(mode = AdviceMode.PROXY)
@EnableAspectJAutoProxy(proxyTargetClass = true)
//Mapper接口扫描
@MapperScan(annotationClass = MyBatisMapper.class, basePackages = {"com.ivmall.mapper"}, sqlSessionFactoryRef = "sqlSessionFactory")
public class AppConfig {
@Autowired
Environment environment;
/**
* DataSource配置
*
* @return
*/
@Bean(name = "dataSource", destroyMethod = "close")
public BoneCPDataSource dataSource() {
BoneCPDataSource dataSource = new BoneCPDataSource();
dataSource.setDriverClass(environment.getProperty("jdbc.driver"));
}