OpenUI5 boilerplate based on OLingo, JPA and Spring Boot
It happens quite often that you quickly want to get something running with OpenUI5 and OData, quickly smack it on a web-server or cloud instance, but just don’t look forward building the project completely start from scratch. Think hackathons, in which time is very limited already… That’s when an OpenUI5 boilerplate would come in handy.
That’s why I have compiled a relatively small application that connects to a database (mysql by default), builds to a jar, allows you to model your data using JPA (and the JPA diagram editor), exposes the model through OData and has a tiny OpenUI5 application that uses the OData and shows the content of the database.
For convenience, a base-diagram for the JPA diagram editor has been provided as well. Once the datamodel is finished, the application with update the data model of the connected database on first run.
By default, the application comes with just one entity: Members, that is automatically populated with a few names from Application.java
Once the application is running, you can browse to http://localhost:8080 to run the sample OpenUI5 application that is using the OData service. The service itself is available from http://localhost:8080/odata.svc.
The only thing you need for this, is a local install of Maven and Java 1.8, once you have that just clone the github repository to your computer:
git clone https://github.com/jpenninkhof/odata-boilerplate.git
Modify file “/src/main/resources/application.properties” to connect to your own database.
And run it:
mvn spring-boot:run
On first run, the application will introspect the database that it has been connected to, and will make sure the database is in sync with it’s internal model. If necessary tables will be created or altered.
And with that, you’re ready to run the OpenUI sample app from http://localhost:8080/openui5-boilerplate
Contributions are welcome. Just fork it and submit a pull request.
Related links:
- Git repo here: https://github.com/jpenninkhof/odata-boilerplate/
- OpenUI5: http://openui5.org/
- Spring Boot: http://projects.spring.io/spring-boot/
- Olingo: https://olingo.apache.org/
- OData: http://www.odata.org/
Interesting stuff Jan! Thanks for sharing this with the community!
Regards,
Robin
Very nice indeed! Could you maybe provide an example with eclipselink and local embedded derby database? I am struggling a little here 😉
Regards
Mathias
Hello Jan,
I did not invest so much time (yet) but I found very interesting to get a quick start project having odata/springboot and ui5 ready to be used. Very nice and clever idea.
I did a clone and followed your instructions but I already face a spring issue. As the error is located deep into spring layers, I have no idea what is happening here. But maybe you will have some ideas.
The error is (after doing a 'clean install' then a 'spring-boot:run'):
In case you can double check if your project still works, or is now broken due to some updates in spring boot.
Thanks 🙂
Guillaume
Hi Guillaume, Could it be that you didn't pick Tomcat as your runtime?
If you didn't, could you try running it on a "Java Web Tomcat 7" runtime instead?
Cheers,
Jan
I can try again, using eclipse.
But I was only launching using the command line ('mvn spring-boot:run' or 'mvn spring-boot:run -P jar') and I don't think there that you need any runtime defined.
I will let you know in case defining a runtime helps.
Regards,
Guillaume
Ah, gotcha!
If you're running it directly using `mvn spring-boot:run -P jar`, you have to make sure that you have made the application.properties file point to a valid database. You could e.g. comment the HCP DB settings in that file and uncomment HSQLDB.
If you link the app to a HSQLDB database, you need to add a HSQLDB driver to the pom.xml as well. I have also modified the github repo a bit so that HSQLDB is automatically included, so you can choose to manually modify the pom.xml, or pull the latest version from the git repo.
In short:
1. git clone https://github.com/jpenninkhof/odata-boilerplate.git
2. Modify application.properties (comment HCP DB portion, uncomment HSQLDB portion)
3. Run `mvn spring-boot:run -P jar`
4. Point your browser at http://localhost:8080
Cheers,
Jan
Thanks for updating so fast 😀 I now am able to run it locally using HSQLdb.
Many thanks !
That's awesome! Great that you got it to work 🙂
Hi,
I create a similar project. It is by far not using all the features that you are using but nevertheless it runs out of the box with wildfly and the embedded H2 database.
https://github.com/ManuelB/blueprint
Hope that helps
Manuel