Java
REVIEWHere’s a list of our preferred technology choices when implementing in Java. We’re not prescriptive in these choices, but have a good reason to deviate from the norm. If you feel there’s a better option, raise it at the Developer Community.
Java language versions
Refer to the Release adoption schedule
Java projects must:
- define the source and target Java version in the Maven
pom.xml
file - use a Java Version Manager such as JEnv to manage Java versions in development
IDE
Choose whatever you’re comfortable with, so long as you can perform your job. Our developers tend to select one of
Build
- Maven is our standard Java build tool
- Code coverage with JaCoCo and the JaCoCo Maven plugin
- Static analysis with SonarQube and the SonarScanner Maven plugin
Application
Our standard Java application stack is built on the Spring ecosystem.
- Applications run in Spring Boot with Apache Tomcat as the embedded application server
- User interfaces with Spring MVC and Thymeleaf 3 for templates
- Web services with Spring MVC or Spring Data Rest and Jackson for JSON mapping
- Security with Spring Security
- Data access with Spring Data JPA and Hibernate ORM
- Batch with Spring Batch
- Cloud integration with Spring Cloud
- Enterprise Integration Patterns (EIP) using Spring Integration
We generally use core Java and standard extension packages in preference to third party, although Spring is often used in preference where available:
- Dates and Times using
Java.time
and notjoda
orjava.util
- Transactions using Java Transaction API (
javax.transaction
) - Object Relational Mapping using Java Persistence API (
javax.persistence
) backed by Hibernate ORM - Validation with JSR-303 (
javax.validation
) backed by Hibernate Validator
We also use other well known libraries:
- Auto-generate boilerplate code with Lombok
- OpenAPI V3 using Springdoc OpenAPI
- Logging API with logging_slf4j, annotated with Lombok @Slf4J and implemention by Logback
- Object mapping is varied. Many projects use Mapstruct or Lombok builder
- Audit using Javers
- We use Apache commons when Spring equivalents are unsuitable
Testing
- JUnit 5 as our core testing framework
- Prefer AssertJ for assertions over Hamcrest matchers
- Mockito for mocking of downstream dependencies
- Spring Test including MockMvc and DataJpaTest
- Unit tests run within the Maven
test
phase with surefire plugin - Integrations tests run within the Maven
integration-test
phase with failsafe plugin.
Improve the playbook
If you spot anything factually incorrect with this page or have ideas for improvement, please share your suggestions.
Before you start, you will need a GitHub account. Github is an open forum where we collect feedback.
Published:
Last reviewed:
Next review due: