Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade: spring boot to 3.x latest #149

Merged
merged 6 commits into from
Dec 13, 2024
Merged
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
4 changes: 2 additions & 2 deletions .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 11
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '11'
java-version: '17'
distribution: 'temurin'
cache: maven
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
Expand Down
98 changes: 13 additions & 85 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.9.RELEASE</version>
<relativePath></relativePath>
<version>3.3.6</version>
<relativePath/>
</parent>

<description>This application shows a few key concepts of
Expand Down Expand Up @@ -78,9 +78,11 @@
</scm>

<properties>
<java.version>11</java.version>
<junit-jupiter.version>5.9.1</junit-jupiter.version>
<!--<assertj.version>3.8.0</assertj.version>-->
<java.version>17</java.version>
c5ms marked this conversation as resolved.
Show resolved Hide resolved
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>

<build>
Expand Down Expand Up @@ -117,29 +119,23 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.11.0</version>
<version>2.17.0</version>
</dependency>
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<scope>provided</scope>
<version>4.0.1</version>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-spring</artifactId>
Expand All @@ -148,74 +144,10 @@
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-broker</artifactId>
</dependency>
<dependency>
<groupId>org.apache.xbean</groupId>
<artifactId>xbean-spring</artifactId>
<version>4.23</version>
</dependency>
<dependency> <!-- Required by Hibernate in Java 11+ -->
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
<version>2.3.3</version>
</dependency>
<dependency> <!-- Required by Hibernate in Java 11+ -->
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.3.3</version>
<scope>runtime</scope>
</dependency>
<dependency> <!-- Required by Hibernate in Java 11+ -->
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.30.2-GA</version>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</exclusion>
<exclusion>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
</exclusion>
<exclusion>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.10.2</version>
<scope>test</scope>
</dependency>
<dependency> <!-- Overridden version required for Java 11 -->
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>5.3.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<version>5.3.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy</artifactId>
<version>1.14.4</version>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
Expand All @@ -225,12 +157,8 @@
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>htmlunit-driver</artifactId>
<scope>test</scope>
</dependency>
<!-- <dependency>--> <!-- Used to generate OpenAPI docs -->
<!-- <groupId>org.springdoc</groupId>-->
<!-- <artifactId>springdoc-openapi-webmvc-core</artifactId>-->
<!-- <version>1.6.12</version>-->
<!-- </dependency>-->
</dependencies>

<repositories>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.pathfinder.api.GraphTraversalService;
import com.pathfinder.api.TransitEdge;
import com.pathfinder.api.TransitPath;

import java.time.Instant;
import java.time.temporal.ChronoUnit;
import java.util.*;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import se.citerus.dddsample.domain.model.handling.HandlingHistory;

import java.lang.invoke.MethodHandles;
import java.util.Objects;

public class CargoInspectionServiceImpl implements CargoInspectionService {

Expand All @@ -32,7 +33,7 @@ public CargoInspectionServiceImpl(final ApplicationEvents applicationEvents,
@Override
@Transactional
public void inspectCargo(final TrackingId trackingId) {
Validate.notNull(trackingId, "Tracking ID is required");
Objects.requireNonNull(trackingId, "Tracking ID is required");

final Cargo cargo = cargoRepository.find(trackingId);
if (cargo == null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package se.citerus.dddsample.application.util;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.Instant;
import java.time.format.DateTimeParseException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,43 +25,36 @@
import se.citerus.dddsample.infrastructure.sampledata.SampleDataGenerator;
import se.citerus.dddsample.interfaces.InterfacesApplicationContext;

import javax.persistence.EntityManager;

@Configuration
@Import({InterfacesApplicationContext.class, InfrastructureMessagingJmsConfig.class})
public class DDDSampleApplicationContext {

@Autowired
CargoRepository cargoRepository;
private CargoRepository cargoRepository;

@Autowired
LocationRepository locationRepository;
private VoyageRepository voyageRepository;

@Autowired
VoyageRepository voyageRepository;
private LocationRepository locationRepository;

@Autowired
GraphTraversalService graphTraversalService;
private HandlingEventRepository handlingEventRepository;

@Autowired
RoutingService routingService;
private GraphTraversalService graphTraversalService;

@Autowired
HandlingEventFactory handlingEventFactory;

@Autowired
HandlingEventRepository handlingEventRepository;

@Autowired
ApplicationEvents applicationEvents;
private ApplicationEvents applicationEvents;

@Bean
public CargoFactory cargoFactory() {
return new CargoFactory(locationRepository, cargoRepository);
}

@Bean
public BookingService bookingService(CargoFactory cargoFactory) {
public BookingService bookingService(CargoFactory cargoFactory,RoutingService routingService) {
return new BookingServiceImpl(cargoRepository, locationRepository, routingService, cargoFactory);
}

Expand All @@ -71,7 +64,7 @@ public CargoInspectionService cargoInspectionService() {
}

@Bean
public HandlingEventService handlingEventService() {
public HandlingEventService handlingEventService(HandlingEventFactory handlingEventFactory) {
return new HandlingEventServiceImpl(handlingEventRepository, applicationEvents, handlingEventFactory);
}

Expand All @@ -86,16 +79,15 @@ public RoutingService routingService() {
}

@Bean
public SampleDataGenerator sampleDataGenerator(CargoRepository cargoRepository, VoyageRepository voyageRepository,
LocationRepository locationRepository, HandlingEventRepository handlingEventRepository,
PlatformTransactionManager platformTransactionManager, EntityManager entityManager) {
SampleDataGenerator sampleDataGenerator = new SampleDataGenerator(cargoRepository, voyageRepository, locationRepository, handlingEventRepository, platformTransactionManager);
try {
sampleDataGenerator.generate(); // TODO investigate if this can be called with initMethod in the annotation
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e);
}
return sampleDataGenerator;
public SampleDataGenerator sampleDataGenerator(CargoRepository cargoRepository,
VoyageRepository voyageRepository,
LocationRepository locationRepository,
HandlingEventRepository handlingEventRepository,
PlatformTransactionManager platformTransactionManager) {
return new SampleDataGenerator(cargoRepository,
voyageRepository,
locationRepository,
handlingEventRepository,
platformTransactionManager);
}
}
23 changes: 12 additions & 11 deletions src/main/java/se/citerus/dddsample/domain/model/cargo/Cargo.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package se.citerus.dddsample.domain.model.cargo;

import jakarta.persistence.*;
import org.apache.commons.lang3.Validate;
import se.citerus.dddsample.domain.model.handling.HandlingHistory;
import se.citerus.dddsample.domain.model.location.Location;
import se.citerus.dddsample.domain.shared.Entity;
import se.citerus.dddsample.domain.shared.DomainEntity;

import javax.persistence.*;
import java.util.List;
import java.util.Objects;

/**
* A Cargo. This is the central class in the domain model,
Expand Down Expand Up @@ -44,9 +45,9 @@
* in port etc), are captured in this aggregate.
*
*/
@javax.persistence.Entity(name = "Cargo")
@Entity(name = "Cargo")
@Table(name = "Cargo")
public class Cargo implements Entity<Cargo> {
public class Cargo implements DomainEntity<Cargo> {

@Id
@GeneratedValue(strategy = GenerationType.AUTO)
Expand All @@ -70,8 +71,8 @@ public class Cargo implements Entity<Cargo> {
private Delivery delivery;

public Cargo(final TrackingId trackingId, final RouteSpecification routeSpecification) {
Validate.notNull(trackingId, "Tracking ID is required");
Validate.notNull(routeSpecification, "Route specification is required");
Objects.requireNonNull(trackingId, "Tracking ID is required");
Objects.requireNonNull(routeSpecification, "Route specification is required");

this.trackingId = trackingId.idString();
// Cargo origin never changes, even if the route specification changes.
Expand All @@ -85,8 +86,8 @@ public Cargo(final TrackingId trackingId, final RouteSpecification routeSpecific
}

public Cargo(TrackingId trackingId, RouteSpecification routeSpecification, Itinerary itinerary) {
Validate.notNull(trackingId, "Tracking ID is required");
Validate.notNull(routeSpecification, "Route specification is required");
Objects.requireNonNull(trackingId, "Tracking ID is required");
Objects.requireNonNull(routeSpecification, "Route specification is required");
this.trackingId = trackingId.idString();
this.origin = routeSpecification.origin();
this.routeSpecification = routeSpecification;
Expand Down Expand Up @@ -151,7 +152,7 @@ public RouteSpecification routeSpecification() {
* @param routeSpecification route specification.
*/
public void specifyNewRoute(final RouteSpecification routeSpecification) {
Validate.notNull(routeSpecification, "Route specification is required");
Objects.requireNonNull(routeSpecification, "Route specification is required");

this.routeSpecification = routeSpecification;
Itinerary itineraryForRouting = this.itinerary != null && !this.itinerary.isEmpty() ? new Itinerary(this.itinerary) : null;
Expand All @@ -165,7 +166,7 @@ public void specifyNewRoute(final RouteSpecification routeSpecification) {
* @param itinerary an itinerary. May not be null.
*/
public void assignToRoute(final Itinerary itinerary) {
Validate.notNull(itinerary, "Itinerary is required for assignment");
Objects.requireNonNull(itinerary, "Itinerary is required for assignment");

this.itinerary = itinerary.legs();
// Handling consistency within the Cargo aggregate synchronously
Expand Down Expand Up @@ -225,7 +226,7 @@ public String toString() {
return trackingId;
}

Cargo() {
protected Cargo() {
// Needed by Hibernate
}

Expand Down
Loading
Loading