我正在使用 Spring Boot 进行应用程序开发。
我需要它来访问我的应用程序中的 2 个数据库/模式(都在 MySQL 数据库中)。
如何仅使用注释 或application.properties 文件来配置它?
目前我使用的是单一数据库:配置如下
tomcat的context.xml
<Resource name="jdbc/user" auth="Container" type="javax.sql.DataSource"
username="***" password="***" driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/user"/>
和
application.properties 在应用中:
spring.datasource.jndi-name=jdbc/user
spring.jpa.database-platform=org.hibernate.dialect.MySQL5Dialect
spring.jpa.show-sql=false
spring.jpa.hibernate.ddl-auto=validate
我该如何配置,将另一个数据库/模式说成客户到此应用程序中。
提前致谢。
最佳答案
你应该使用2个数据源
链接示例
https://github.com/spring-projects/spring-data-examples/tree/master/jpa/multiple-datasources
关于spring - 如何在应用程序中配置 2 个数据库/模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32722502/