spring-boot jdbc datasource configure?

时间:2017-10-10 19:28:28

标签: spring-boot configuration spring-data datasource spring-jdbc

如果我表达了我的需要,我会请你注意并放纵。 我必须在spring-boot,spring-data-jpa,rest,java8中构建一个多基础应用程序。 IT系统部门提供了不存储登录名和密码的说明。 通常要构建数据源,我们将url,用户和密码存储在application.properties文件或配置文件中。 我所引起的需求已经发生了变化。 我已经设计了我的实体,存储库,服务和控制器。 IT系统部门希望能够让管理员在主页中输入密码和登录(我不是在谈论弹簧认证)

看看这个:

 @Bean
    public DataSource dataSource() {
     DataSource dataSource = new DataSource();
     dataSource.setUrl(url);                        
     dataSource.setUsername(user);//unknown,wait admin to enter this user
     dataSource.setPassword(pwd);//unknown,wait admin to enter this pwd
     return dataSource;
    }

你有没有处理过这种问题? 你有一个具体的例子(github或教程?) 提前谢谢。

1 个答案:

答案 0 :(得分:0)

你应该做两件事:
(1)提供RESTful API等Web服务,从主页发送的请求中获取用户名/密码 (2)根据给定的URL,用户名和密码建立数据库连接。

相关问题