如何在不使用Application.properties的情况下在Spring Boot中创建DB2连接?
我需要建立与DB2数据库的连接,但是我无法使用Application.properties,因此如何创建此连接?
I need to build a connection to db2 database, but I can not use application.properties at this moment, so how can I create this connection?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以在应用程序本身中实现
dataSource
bean。例如:然后,请确保对数据源的任何自动引用为“懒惰”,因此该应用程序有时间加载属性(也许来自另一个文件)并实例化数据源,如:
You can implement a
datasource
bean in the app itself. For example:Then, make sure any autowired references to the data source are "lazy", so the app has time to load the properties (maybe from another file) and to instantiate the data source, as in: