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;
}
}
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.118.2.225