Developing a web application with Spring Boot, AngularJS and Java 8
And if you’re feeling
You’ve got everything you came for
If you got everything
And you don’t want no moreYou’ve got to just
Keep on pushing
Keep on pushing
Push the sky away
“Push The Sky Away” by Nick Cave & The Bad Seeds.
This is gonna be a lengthy post about always learning new things and improving old ones.
This is gonna be the 1st post of a series about learning new things and creating a modern Java application from start. In the first part I’m gonna write about the idea, the tools and the project itself.
All posts
- Part 1: Boot your application with Spring Boot
- Part 2: Using Java 8 .now()
- Part 3: Messaging and Websockets with Spring 4
- Part 4: Spring Boot as a backend for AngularJS
- Bonus: Creating a JavaFX 8 frontend for a REST application
The idea and purpose of this thing
I had several reasons to create a project with well defined goals and requirements the way it should be.
The last weeks i had often discussions with current and possible future customers about the number or the price of my hours and i tried to tell them, that neither the price was too high or the number of estimated hours, especially the later, far from. I needed a reasonable sized and manageable project to prove this.
I also need to convince my colleges that near 100% test coverage and that database testing is possible and i also need to demonstrate that today a “one-guy-does-the-whole-stack” thing is nearly impossible if you don’t want to not sleep like me for about 2 weeks (or you’re just crazy about this stuff (also like me)).
And the most important reason for me is to learn something new, in this case learn about the new features in the upcoming release of Java 8.
Choosing the tools of the trade
Since 2010/11 i had real fun migration my daily picture project Daily Fratze from Ruby on Rails to Java, using the great Spring framework, so the first ingredient will be Spring but with it’s latest incarnation, Spring Boot: “Spring Boot favors convention over configuration and is designed to get you up and running as quickly as possible.”.
Certainly a new app will be written using Java 8. Just have a look at this post “Everything about Java 8” if you need reasons.
I need a database and i’m still a huge fan of relational databases and so i need some JPA 2.1. To make my life easier, i chose Spring Data JPA together with a little embedded H2 Database.
And finally AngularJS. I’m a little bit old school, i like my html pages server generated but i wanted to know what all the cool kids are doing and learn something fresh. Also, i thought it would be useful in the goal of designing a nice api.
Putting it all together with: NetBeans. I’m an Eclipse user since about 2002 and it’s hard to teach an old dog new tricks, but Eclipse has no Java 8 support. The alternative, IntelliJ didn’t really click with my. It incredible slow on an 2012 iMac with 16Gb Ram, doesn’t feel right to me and has some things i really hate (for example, what’s with those xml files that are created for every maven dependency?) so i thought why not given NetBeans another try.
I remember NetBeans being slow (and ugly), but 7.4 just proved me wrong. It’s fast and snappy and as i mentioned, it’s Maven support just outstanding, namely: It just works. Just 2 additional config files in a Maven project and that’s it. All the pain i had to go through to make Eclipse m2e work with generated source file, assisted JPA classes and aspects: It just worked in NetBeans. Awesome.
The project
Simple, recreating my Ruby / Sinatra based biking application: biking.michael-simons.eu. The original application is a very condensed Ruby script, which worked very well, but it’s not very maintainable.
So goto biking.michael-simons.eu and have a look. The thing is live and runs on the Java 8 release candidate. The source code is available at GitHub.
I’d be more than happy about comments, recommendations and ideas.