- Hands-On Spring Security 5 for Reactive Applications
- Tomcy John
- 50字
- 2021-07-23 18:59:21
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;
}
}