- This a sample project for IBM MobileFirst Platform + Spring + Hibernate/JPA + MySQL
- Installed Java JDK 1.8.x
- Installed MySQL 8.x.x and create a local database connection.
- Installed Apache Maven 3.6.x
- Installed any preferred IDE. Recommended to use Eclipse 2019-03.
- Installed Apache Lombok 1.x.x in IDE.
- Git clone and setup
https://github.com/yousoff92/spring-hibernate
- Installed IBM MobileFirst Platform
http://mobilefirstplatform.ibmcloud.com/downloads/
Setup spring-hibernate
cd
tospring-hibernate
and executemvn clean install
to generate jar file.- Generate the jar file again if we do any changes in the project.
Setup IBM MobileFirst Platform
cd
to../mfp-server/usr/servers/mfp
- Open IBM MFP server.xml and add the following lines :
<!-- Yousoff: Added configuration for JDBC -->
<!-- Ref : https://www.ibm.com/support/knowledgecenter/SSD28V_9.0.0/com.ibm.websphere.wlp.core.doc/ae/twlp_dep_configuring_ds.html -->
<!-- Must specify Datasource -->
<dataSource id="DefaultDataSource" jndiName="jdbc/mysql" type="javax.sql.DataSource">
<jdbcDriver libraryRef="MySQLLib" javax.sql.DataSource="com.mysql.cj.jdbc.MysqlDataSource"/>
<properties url="jdbc:mysql://localhost:3306/mydb?useSSL=false&allowPublicKeyRetrieval=true" user="root" password="password"/>
</dataSource>
<library id="MySQLLib">
<file name="/home/yousoff/Documents/library/mysql-connector-java-8.0.11.jar"/>
</library>
- Modify the JDBC URL and point the MySQL Connector jar file to the correct path.
- In terminal, execute the
run.sh
to start local MFP server athttp://localhost:9080/mfpconsole
Setup mfp-spring-adapter
cd
tomfp-spring-adapter
project and build adapter by executingmvn clean install
- Deploy to local MFP by executing
mvn adapter:deploy
- Make sure MySQL Connector version match your local MySQL DB version. Let say your DB is 5.x.x, then change then server.xml to 5.x.x.