简体   繁体   English

HikariCP上的属性文件

[英]Properties file on HikariCP

I tried unsuccessfully configure hikaricp and I don't see error in the code please help. 我尝试配置hikaricp失败,并且在代码中看不到错误,请提供帮助。

public class DatabaseManager {

    private DatabaseClient[] databaseClients;
    private HikariDataSource hikariDataSource;

    public DatabaseManager(String absoluteFilePath) {
        final HikariConfig hikariConfig = new  HikariConfig(absoluteFilePath);
        this.hikariDataSource = new HikariDataSource(hikariConfig);
        System.out.println(hikariConfig.getUsername()); // null u-u
    }
}

Properties file: 属性文件:

## Database Settings
dataSourceClassName=org.mariadb.jdbc.MySQLDataSource
dataSource.user=root
dataSource.password=
dataSource.databaseName=imagine-db
dataSource.portNumber=3306
dataSource.serverName=localhost

You've set the username on the data source not on the config itself. 您已经在数据源上而不是在配置本身上设置了用户名。 This will still work fine but you can't access it using hikariConfig.getUsername() . 这仍然可以正常工作,但是您无法使用hikariConfig.getUsername()访问。

Try adding this to your properties file if you really need to access the user like that, although I suspect you don't. 如果确实需要像这样访问用户,请尝试将其添加到属性文件中,尽管我怀疑您不需要这样做。

username=root
password=

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM