记一次 oracle not support oracle driver 4.0
package com.positioningsystem.configuration;
import com.alibaba.druid.pool.DruidDataSource;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.SqlSessionFactoryBean;
import org.mybatis.spring.annotation.MapperScan;
import org.mybatis.spring.mapper.MapperScannerConfigurer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import javax.sql.DataSource;
import java.sql.SQLException;
@Configuration
public class DBConfiguration {
@Value("${}")
private String url;
@Value("${}")
private String username;
@Value("${}")
private String passowrd;
@Value("${-class-name}")
private String drivername;
private static final String mapperlocations = "classpath:mapper/*.xml";
private static final String pageScanse = "";
@Primary
@Bean(name = "mainDatabase")
@ConfigurationProperties(prefix = "")
public DataSource druid(){
DruidDataSource druidDataSource = new DruidDataSource();
druidDataSource.setInitialSize(30);
druidDataSource.setMaxActive(200);
druidDataSource.setMinIdle(50);
druidDataSource.setMaxWait(600000);
try {
druidDataSource.setFilters("stat,wall");
}catch (SQLException e){
e.printStackTrace();
}
return druidDataSource;
}
@Bean(name = "mainSqlSessionFactory")
@Primary
public SqlSessionFactory getSqlSessionFactory(@Qualifier("mainDatabase") DataSource dataSource) throws Exception{
SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();
sqlSessionFactoryBean.setDataSource(dataSource);
sqlSessionFactoryBean.setMapperLocations(new PathMatchingResourcePatternResolver().getResources(mapperlocations));
sqlSessionFactoryBean.setTypeAliasesPackage(pageScanse);
return sqlSessionFactoryBean.getObject();
}
}