一、利用@PropertySource获取resource下面的资源,Environment获取属性
@Configuration
@EnableTransactionManagement
@PropertySource(value = {"classpath:DBsource.properties"})
public class DBBeanConfig {
@Autowired
private Environment env;
@Bean(destroyMethod = "close")
public DataSource dataSource(){
DruidDataSource dataSource = new DruidDataSource();
dataSource.setDriverClassName(env.getProperty("source.driverClassName").trim());
dataSource.setUrl(env.getProperty("source.url").trim());
dataSource.setUsername(env.getProperty("source.username").trim());
dataSou