首页 > 其他分享 >JdbcConfig

JdbcConfig

时间:2022-10-18 08:55:44浏览次数:51  
标签:username jdbc String Value private JdbcConfig druidDataSource

JdbcConfig

jdbc.properties注解版

@Value("${jdbc.driver}")
    private String driver;

    @Value("${jdbc.url}")
    private String url;

    @Value("${jdbc.username}")
    private String username;

    @Value("${jdbc.password}")
    private String password;

    @Bean
    public DataSource dataSource() {
        DruidDataSource druidDataSource = new DruidDataSource();
        druidDataSource.setDriverClassName(driver);
        druidDataSource.setUrl(url);
        druidDataSource.setUsername(username);
        druidDataSource.setPassword(password);

        return druidDataSource;
    }

标签:username,jdbc,String,Value,private,JdbcConfig,druidDataSource
From: https://www.cnblogs.com/chenhuohuo/p/16801419.html

相关文章