Creating & Pushing a Java MicroService
What would it take to create a Java backend service hosted on Predix ?
Answer
Its just a couple of clicks away, without even having to right any code.
Steps
- Go to start.spring.io
- Enter
Group
information , For me I enteredcom.sks.predix.sample
- Enter
artifact
info , I enteredtodo-service
as I'll be writing a backed to store the to-do frontend developed in the other chapter - Select the required dependencies , For me I am interested in Web , Actuator, JPA and h2 for now
- Click on Generate Project to start downloding the zip
- Open the zip and the resulting folder is your application
- Checkout this commit for details on how the project looks like
- Try running
mvn spring-boot:run
and goto http://localhost:8080/env - This should open up the Spring Actuator which is really helpful in checking out the application container properties and couple of other parameters which will be covered later
- Time to add manifest.yml to set properties for the project. checkout this commit
- Its time to
cf push
- Once pushed, checkout the app in Cloud , by going to https://todo-server.run.aws-usw02-pr.ice.predix.io/env, Change
todoservice
with whatever entry you have given for your hostname in the manifest.yml
Tips
- At any time if you want to see what your application is doing, just type
cf logs <APP_NAME>
, for eg:cf logs todo-service