如何在Spring Boot中配置第二个数据库(仅用于Select查询)

huangapple go评论62阅读模式
英文:

How to configure second database (For only Select queries) in Spring Boot

问题

我有一个Spring Boot项目,已经配置好了一个MySQL数据库以及迁移脚本。

我有一个新的需求,需要将一个Oracle数据库(属于另一个应用程序)配置到我的应用程序中。

我理解在Spring Boot项目中可以配置多个数据库。但我需要配置Oracle数据库,以便不将为MySQL编写的迁移脚本应用到它上,因为我只需要在Oracle数据库上执行选择查询。

我希望将Oracle数据库配置为只读数据库,而不影响现有的MySQL数据库配置。

英文:

I have a spring boot project with a MySql DB already configured along with the migration scripts.

I have a new requirement where I have to configure an Oracle database(part of another application) to my application.

I understand that we can configure multiple databases in spring boot project. But I need to configure Oracle DB such that the migration scripts writtrn for MySQL doesn't apply onto it as I have to perform only select queries on Oracle database.

I am expecting to configure the Oracle database as a read only database without affecting the existing configuration for MySQL database.

答案1

得分: 1

最简单的解决方案是在Oracle数据库中创建一个只读用户,并在application.properties文件中,用只读用户的信息替换旧数据库用户的信息。

英文:

The easiest solution would be creating a read-only user in the Oracle database, and in the application.properties file, you should replace the old database user information with the read-only user's information.

huangapple
  • 本文由 发表于 2023年2月26日 20:23:02
  • 转载请务必保留本文链接:https://go.coder-hub.com/75571945.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定