Spring Boot + Hibernate + Multiple Datasource (Part.1)

Spring Boot 2.x + Hibernate 5.x + Multiple Datasource - Init Project

Before start

The new project is required to use new platform, which we will abandon the historical architecture. It is a challenge and need to make a courage to move a comfortable bed to a rough floor.

The previous platform is built by Spring framework 4.x + Hibernate 3.x. All modules are intergrated in one Java project. Everything runs smoothly and easy to add new moudle in it (despite the transaction has a little bit problem, occasionally cannot rollback by transaction manager )

Why we plan to move spring boot, should be another topic, but before we really copy and paste business code, the architecture should satisfy basic requirement: database CRUD.

The first topic is, connect to multiple brand database and execute CRUD

Init the project

By the IntelJ help, to init a new project is a unbelieveably simple task, here is the step:

  1. Use Spring Initialzr
    1Spring Initialzr

  2. Input the aritfact etc.
    Ingore this part, please follow guide

  3. Choose the dependencies
    JPA is necessary, other brand database should follow your need.
    Please beware, there is no Oracle driver because license prohibit
    在这里插入图片描述

  4. Finish the project init

Complete the maven dependencies

Base on project requirement to complete the dependencies.
One thing need to reminder
if you connect to Oracle database, the OJDBC driver should be new verion
ojdbc version should upgrade to 11g or above, because there are some bugs between java and JPA, hibernate version
There is a download link:
https://www.oracle.com/technetwork/documentation/jdbc-112010-090769.html

<dependency>
	<groupId>com.oracle</groupId>
	<artifactId>ojdbc16</artifactId>
	<version>11.2.0.4</version>
</dependency>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值