| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
This project is intended to serve as a CRUD archetype using Spring Boot and Spring Data in an imperative (non-reactive) way. It is also intended to demonstrate the use of Aspect Oriented Programming (AOP) for trace logging, database exception conversion, and annotation based event processing. More information about the use of AOP in this application can be found in this [accompanying Medium article] (https://medium.com/ibm-garage/improving-readability-of-java-code-with-aspect-oriented-programming-aop-167b05846190)
Note: To make it easier to use as a demonstration, a H2 in memory database is used with spring data, with the goal being for it to be swapped out for the database of your choice.
This code is meant to be containerized. If you are deploying to Kubernetes you will need to build and containerize the application first.
NOTE: If deploying to OpenShift, how you build may be different depending on your needs and if you use the manifests/openshift/build.yaml as described in the "Deploying to Openshift" section.
NOTE: If you don't want to or can't build it yourself, you can use the container that is deployed in dockerhub at "michaelsteven/springboot-items-api:0.0.1"
Steps:
docker run -v $PWD:/usr/src/springboot-items-api -w /usr/src/springboot-items-api maven:3-eclipse-temurin-17 mvn clean install
docker build -t <<your-registry-namespace>>/springboot-items-api:0.0.1 .
docker login docker push <<your-registry-namespace>>/springboot-items-api:0.0.1
NOTE: Be sure to use your own namespace name instead of "<"
These instructions will walk you through using the helm chart found in the manifests folder of this repository to deploy the application from the command line.
PREREQUISITES:
How to deploy:
kubectl config current-context
kubectl create namespace dev
kubectl create configmap springboot-items-api --from-file=application.yaml -n dev
oc create secret generic mysql-credentials --from-literal=username=root --from-literal=password=password
helm install -f manifests/helm/springboot-items-api/Chart.yaml springboot-items-api -n dev --dry-run ./manifests/helm/springboot-items-api
helm install -f manifests/helm/springboot-items-api/Chart.yaml springboot-items-api -n dev --dry-run ./manifests/helm/springboot-items-api
Explore running in OpenShift with a Developer Sandbox (free) account available in RedHat: https://developers.redhat.com/developer-sandbox.
Below is an step-by-step of a way to build and deploy this microservice using the CLI. They could also be used as part of an external CI/CD pipeline.
oc create configmap springboot-items-api --from-file=application.yaml
oc create secret generic mysql-credentials --from-literal=username=root --from-literal=password=password
oc new-app --file=./manifests/openshift/build.yaml --param=APP=springboot-items-api
oc start-build springboot-items-api --from-dir .
This will build the Dockerfile and publish it into openshift's integrated container registry. 10. Use the deployment template to deploy the application:
oc process -f manifests/openshift/deployment.yaml --param=REGISTRY=image-registry.openshift-image-registry.svc:5000/michael-hepfer-dev | oc apply -f -
© Copyright IBM Corporation [2021], [2022].
Licensed under the Apache License, Version 2.0 (the "License"); you may not use these files except in compliance with the License. You may obtain a copy of the License at http://ww.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permission and limitations under the License.
| Back | FazBrowse Home | New Git URL |