官术网_书友最值得收藏!

Step 5—Spring application configuration

Create a Java class named ApplicationConfig with the following code in the com.packtpub.book.ch02.springsecurity.config package:

@Configuration
@PropertySource("classpath:mysqldb.properties")
public class ApplicationConfig {

@Autowired
private Environment env;

@Bean
public DataSource getDataSource() {
BasicDataSource dataSource = new BasicDataSource();
dataSource.setDriverClassName(env.getProperty("mysql.driver"));
dataSource.setUrl(env.getProperty("mysql.jdbcUrl"));
dataSource.setUsername(env.getProperty("mysql.username"));
dataSource.setPassword(env.getProperty("mysql.password"));
return dataSource;
}
}
主站蜘蛛池模板: 建瓯市| 古交市| 宁海县| 松滋市| 大方县| 应用必备| 彰武县| 岳阳市| 昆山市| 江安县| 长顺县| 张家港市| 丹东市| 报价| 兴安盟| 五常市| 岳池县| 香河县| 富阳市| 青海省| 崇文区| 道孚县| 道真| 永昌县| 马关县| 赣榆县| 通海县| 南城县| 个旧市| 汉川市| 民勤县| 青州市| 和田县| 蒲城县| 平南县| 新河县| 永修县| 清水河县| 江孜县| 会东县| 漠河县|