Develop a containerized Spring Boot project based on this template project.
A basic starter app that provides an index.html, as well as a JSON response on GET /greeting.
Includes actuator endpoints on another port (8081):
/_manage/info, that provides build information (such as git commit id), and/_manage/metricsfor runtime metrics.
Includes Distributed tracing Using Zipkin as the implementation
Note: Before building this project in Jenkins, change the project name in the Jenkinsfile!
git clone https://tools.adidas-group.com/bitbucket/scm/dof/spring-boot-seed.git --depth 1cd spring-boot-seed- Edit
Jenkinsfilereplacing springboot-seed with your new project name mvn packagejava -jar target/springboot-seed-0.1.0.jar- Optional (only for tracing)
docker run -d -p 9411:9411 openzipkin/zipkin - Open http://localhost:8080 in your browser
See Deployment for how to deploy on a local k8s cluster or onto the Giantswarm cluster.
Setting up as a Jenkins2 pipeline job, it uses the Jenkinsfile which is part of the source code.
More details: https://jenkins.io/doc/book/pipeline/
Run mvn jacoco:report
For code coverage the jacoco Maven plugin has been included. This plugin creates the file target/jacoco.exec which can be uploaded to sonarqube.
Additionally in target/site/jacoco a human readable report is created.
Place integration tests in src/test/**/*IT.java, so the maven failsafe plugin picks them up.
To execute integration tests, run mvn compile compiler:testCompile failsafe:integration-test failsafe:verify.
Automated UI-Tests are done using selenium and cucumber-jvm. Our working example is an adaptation of java-webbit-websockets-selenium. To run it locally, follow the UI-Test instructions.
- Products Page
/productsshows a list of products. The products data is fetched from another service. To configure this service endpoint, you need to set the environment variablesK8S_CATALOG_SERVICE_PROTOCOL,K8S_CATALOG_SERVICE_HOST,K8S_CATALOG_SERVICE_PORT. An example configuration could be:
K8S_CATALOG_SERVICE_PROTOCOL=http
K8S_CATALOG_SERVICE_HOST=adidas-springboot-api-seed-master.dof
K8S_CATALOG_SERVICE_PORT=8080
Service classes should have a fallback method when performing network calls to other services (Circuit breaker pattern). An example implementation is given in the ProductService class, its test in the ProductServiceCircuitBreakerIT class.
Note: Sensitive data, such as system metrics is mounted on a different port (8081) than the main app.
-
Metrics endpoint ':8081/_manage/metrics` shows system metrics of the running process. Example response:
{ "mem": 649250, "mem.free": 131163, "processors": 8, // ... "gauge.response._manage.info": 91, "counter.status.200._manage.info": 1 } -
Info endpoint :8080/_manage/info shows project info of the app. Example response:
{ "build": { "artifact": "springboot-seed", "name": "springboot-seed", "description": "...", "version": "0.1.0" } }These data are created from the maven pom file and from the git meta info created while building: ('git.properties').
OAuth2 connectors are configured via the oauth2 section of the application.yml. An example SSO endpoint is included with the project. For detailed documentation, see OAuth2.
Spring recommends naming the log4j2 configuration file log4j2-spring.xml - however this leads to an error message during startup:
ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging only errors to the console.
This is a known and open issue: spring-projects/spring-boot#4809
For this reason, the logging configuration file uses the standard log4j2 naming, i.e. log4j2.xml