Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions .github/rulesets/master.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"id": 4327583,
"id": 4559383,
"name": "master",
"target": "branch",
"source_type": "Repository",
Expand Down Expand Up @@ -43,7 +43,15 @@
"do_not_enforce_on_create": false,
"required_status_checks": [
{
"context": "lint",
"context": "build (check)",
"integration_id": 15368
},
{
"context": "build (test)",
"integration_id": 15368
},
{
"context": "Analyze (java)",
"integration_id": 15368
}
]
Expand Down
9 changes: 3 additions & 6 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,12 @@
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"
name: CodeQL

on:
push:
branches: [ "master" ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ "master" ]
branches:
- master
schedule:
- cron: '36 5 * * 4'

Expand Down Expand Up @@ -61,7 +59,6 @@ jobs:
distribution: 'temurin' # See 'Supported distributions' for available options
java-version: '21'


# Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
Expand Down
17 changes: 5 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,16 @@

## Purpose

The purpose of this template is to speed up the creation of new Spring applications within HMCTS
and help keep the same standards across multiple teams. If you need to create a new app, you can
simply use this one as a starting point and build on top of it.
The purpose of this template is to speed up the creation of new Spring applications within HMCTS.

## What's inside

The template is a working application with a minimal setup. It contains:
* application skeleton
* setup script to prepare project
* common plugins and libraries
* Standard plugins and libraries
* [HMCTS Java plugin](https://github.com/hmcts/gradle-java-plugin)
* docker setup
* automatically publishes API documentation to [hmcts/cnp-api-docs](https://github.com/hmcts/cnp-api-docs)
* code quality tools already set up
* MIT license and contribution information
* Helm chart using chart-java.

Expand Down Expand Up @@ -85,10 +81,6 @@ The template contains the following plugins:
./gradlew dependencyUpdates -Drevision=release
```

## Setup

Located in `./bin/init.sh`. Simply run and follow the explanation how to execute it.

## Building and deploying the application

### Building the application
Expand All @@ -110,9 +102,10 @@ Create the image of the application by executing the following command:
./gradlew assemble
```

Note: Docker Compose V2 is highly recommended for building and running the application.
In the Compose V2 old `docker-compose` command is replaced with `docker compose`.
Local installation of docker: [Get Docker](https://docs.docker.com/get-started/get-docker/)
```

```
Create docker image:

```bash
Expand Down
8 changes: 2 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -218,12 +218,8 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter-json'
implementation group: 'org.springdoc', name: 'springdoc-openapi-starter-webmvc-ui', version: '2.8.6'

implementation group: 'com.github.hmcts.java-logging', name: 'logging', version: '6.1.8'

implementation group: 'org.apache.logging.log4j', name: 'log4j-api', version: log4JVersion
implementation group: 'org.apache.logging.log4j', name: 'log4j-to-slf4j', version: log4JVersion
implementation group: 'ch.qos.logback', name: 'logback-classic', version: logbackVersion
implementation group: 'ch.qos.logback', name: 'logback-core', version: logbackVersion
implementation 'com.microsoft.azure:applicationinsights-spring-boot-starter:2.6.4'
implementation 'net.logstash.logback:logstash-logback-encoder:7.4'

implementation group: 'io.rest-assured', name: 'rest-assured', version: '5.5.1'

Expand Down
5 changes: 5 additions & 0 deletions src/main/java/uk/gov/hmcts/cp/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@SpringBootApplication
@SuppressWarnings("HideUtilityClassConstructor")
public class Application {

private static final Logger logger = LoggerFactory.getLogger(Application.class);

public static void main(final String[] args) {
logger.info("Starting Spring Boot application...");
SpringApplication.run(Application.class, args);
}
}
15 changes: 15 additions & 0 deletions src/main/java/uk/gov/hmcts/cp/config/ApplicationConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package uk.gov.hmcts.cp.config;

import com.microsoft.applicationinsights.TelemetryClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class ApplicationConfig {

@Bean
public TelemetryClient getTelemetryClient() {
return new TelemetryClient();
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package uk.gov.hmcts.cp.controllers;

import com.microsoft.applicationinsights.TelemetryClient;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
Expand All @@ -8,14 +9,18 @@
import uk.gov.hmcts.cp.openapi.model.CourtHousesschema;
import uk.gov.hmcts.cp.services.OpenApiService;

import java.util.Map;

@RestController
@RequiredArgsConstructor
public class OpenApiController implements DefaultApi {

private final OpenApiService openApiService;
private final TelemetryClient telemetryClient;

@Override
public ResponseEntity<CourtHousesschema> courthousesCourtIdGet(String courtId) {
telemetryClient.trackEvent("GETCourthouseCourt", Map.of("courtId", courtId), null);
CourtHousesschema courtHousesschema = openApiService.getCourtHouse(courtId);
return new ResponseEntity<>(courtHousesschema, HttpStatus.OK);
}
Expand Down
31 changes: 5 additions & 26 deletions src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,10 @@ server:
port: 4550
shutdown: "graceful"

# If you use a database then uncomment the `group:, readiness: and include: "db"` lines in the health probes and uncomment the datasource section
management:
endpoint:
health:
show-details: "always"
# group:
# readiness:
# include: "db"
endpoints:
web:
base-path: /
Expand All @@ -24,29 +20,12 @@ spring:
config:
import: "optional:configtree:/mnt/secrets/rpe/"
application:
name: Spring Boot Template
# datasource:
# driver-class-name: org.postgresql.Driver
# url: jdbc:postgresql://${DB_HOST}:${DB_PORT}/${DB_NAME}${DB_OPTIONS:}
# username: ${DB_USER_NAME}
# password: ${DB_PASSWORD}
# properties:
# charSet: UTF-8
# hikari:
# minimumIdle: 2
# maximumPoolSize: 10
# idleTimeout: 10000
# poolName: {to-be-defined}HikariCP
# maxLifetime: 7200000
# connectionTimeout: 30000
# jpa:
# properties:
# hibernate:
# jdbc:
# lob:
# # silence the 'wall-of-text' - unnecessary exception throw about blob types
# non_contextual_creation: true
name: ${APP_NAME:Spring Boot Template}

azure:
application-insights:
instrumentation-key: ${rpe.AppInsightsInstrumentationKey:00000000-0000-0000-0000-000000000000}
# cosmos:
# uri: https://<your-account>.documents.azure.com:443/
# key: ${COSMOS_KEY}
# database: my-database-name
12 changes: 12 additions & 0 deletions src/main/resources/logback-spring.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<configuration>
<include resource="org/springframework/boot/logging/logback/defaults.xml"/>
<include resource="org/springframework/boot/logging/logback/console-appender.xml"/>

<appender name="jsonConsole" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="net.logstash.logback.encoder.LogstashEncoder" />
</appender>

<root level="INFO">
<appender-ref ref="jsonConsole"/>
</root>
</configuration>
Loading