Skip to content

Instantly share code, notes, and snippets.

@CheolhoJeon
Last active April 29, 2020 02:02
Show Gist options
  • Save CheolhoJeon/e073a4c6ac369564dda6ac5bd8f50309 to your computer and use it in GitHub Desktop.
Save CheolhoJeon/e073a4c6ac369564dda6ac5bd8f50309 to your computer and use it in GitHub Desktop.
package config;
import org.apache.tomcat.jdbc.pool.DataSource;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class DsConfigWithProp {
@Value("${db.driver}")
private String driver;
@Value("${db.jdbcUrl}")
private String jdbcUrl;
@Value("${db.driver}")
private String user;
@Value("${db.driver}")
private String password;
@Bean(destroyMethod = "close")
public DataSource dataSource() {
DataSource ds = new DataSource();
ds.setDriverClassName(driver);
ds.setUrl(jdbcUrl);
ds.setUsername(user);
ds.setPassword(password);
...
return ds;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment