Skip to content

Commit 2cd2f9c

Browse files
committed
Upgrade to Spring Boot 2.1.5
1 parent 0ac7ab1 commit 2cd2f9c

28 files changed

+145
-118
lines changed

pom.xml

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,23 @@
44
<modelVersion>4.0.0</modelVersion>
55

66
<groupId>org.springframework.samples</groupId>
7-
<artifactId>spring-petclinic</artifactId>
8-
<version>1.5.2</version>
9-
<packaging>war</packaging>
7+
<artifactId>spring-petclinic-rest</artifactId>
8+
<version>2.1.5</version>
109

11-
<name>petclinic</name>
12-
<description>Spring petclinic project</description>
10+
<description>REST version of the Spring Petclinic sample application</description>
11+
<url>https://spring-petclinic.github.io/</url>
1312

1413
<parent>
1514
<groupId>org.springframework.boot</groupId>
1615
<artifactId>spring-boot-starter-parent</artifactId>
17-
<version>1.5.2.RELEASE</version>
18-
<relativePath/> <!-- lookup parent from repository -->
16+
<version>2.1.5.RELEASE</version>
17+
<relativePath/> <!-- lookup parent from Maven repository -->
1918
</parent>
2019

2120
<properties>
22-
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
23-
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
24-
<java.version>1.8</java.version>
25-
2621
<spring-data-jdbc.version>1.2.1.RELEASE</spring-data-jdbc.version>
27-
<cobertura.version>2.7</cobertura.version>
28-
29-
<start-class>org.springframework.samples.petclinic.PetClinicApplication</start-class>
30-
22+
<springfox-swagger.version>2.6.1</springfox-swagger.version>
23+
<jacoco.version>0.8.2</jacoco.version>
3124
</properties>
3225

3326
<!-- repository for springfox plugin -->
@@ -96,11 +89,6 @@
9689
</exclusions>
9790
</dependency>
9891

99-
<dependency>
100-
<groupId>org.springframework.boot</groupId>
101-
<artifactId>spring-boot-starter-tomcat</artifactId>
102-
<scope>provided</scope>
103-
</dependency>
10492
<dependency>
10593
<groupId>org.springframework.boot</groupId>
10694
<artifactId>spring-boot-starter-test</artifactId>
@@ -129,12 +117,12 @@
129117
<dependency>
130118
<groupId>io.springfox</groupId>
131119
<artifactId>springfox-swagger2</artifactId>
132-
<version>2.6.1</version>
120+
<version>${springfox-swagger.version}</version>
133121
</dependency>
134122
<dependency>
135123
<groupId>io.springfox</groupId>
136124
<artifactId>springfox-swagger-ui</artifactId>
137-
<version>2.6.1</version>
125+
<version>${springfox-swagger.version}</version>
138126
</dependency>
139127

140128
<dependency>
@@ -143,13 +131,6 @@
143131
<scope>test</scope>
144132
</dependency>
145133

146-
<dependency>
147-
<groupId>org.hamcrest</groupId>
148-
<artifactId>hamcrest-all</artifactId>
149-
<version>1.3</version>
150-
<scope>test</scope>
151-
</dependency>
152-
153134
<dependency>
154135
<groupId>javax.xml.bind</groupId>
155136
<artifactId>jaxb-api</artifactId>
@@ -162,25 +143,44 @@
162143
<plugin>
163144
<groupId>org.springframework.boot</groupId>
164145
<artifactId>spring-boot-maven-plugin</artifactId>
146+
<executions>
147+
<execution>
148+
<!-- Spring Boot Actuator displays build-related information
149+
if a META-INF/build-info.properties file is present -->
150+
<goals>
151+
<goal>build-info</goal>
152+
</goals>
153+
<configuration>
154+
<additionalProperties>
155+
<encoding.source>${project.build.sourceEncoding}</encoding.source>
156+
<encoding.reporting>${project.reporting.outputEncoding}</encoding.reporting>
157+
<java.source>${maven.compiler.source}</java.source>
158+
<java.target>${maven.compiler.target}</java.target>
159+
</additionalProperties>
160+
</configuration>
161+
</execution>
162+
</executions>
165163
</plugin>
166-
</plugins>
167-
</build>
168-
<reporting>
169-
<plugins>
170-
<!-- integrate maven-cobertura-plugin to project site -->
164+
171165
<plugin>
172-
<groupId>org.codehaus.mojo</groupId>
173-
<artifactId>cobertura-maven-plugin</artifactId>
174-
<version>${cobertura.version}</version>
175-
<reportSets>
176-
<reportSet>
177-
<reports>
178-
<report>cobertura</report>
179-
</reports>
180-
</reportSet>
181-
</reportSets>
166+
<groupId>org.jacoco</groupId>
167+
<artifactId>jacoco-maven-plugin</artifactId>
168+
<version>${jacoco.version}</version>
169+
<executions>
170+
<execution>
171+
<goals>
172+
<goal>prepare-agent</goal>
173+
</goals>
174+
</execution>
175+
<execution>
176+
<id>report</id>
177+
<phase>prepare-package</phase>
178+
<goals>
179+
<goal>report</goal>
180+
</goals>
181+
</execution>
182+
</executions>
182183
</plugin>
183-
</plugins>
184-
</reporting>
185-
<url>demopetclinic</url>
184+
</plugins>
185+
</build>
186186
</project>

readme.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ In its default configuration, Petclinic doesn't have authentication and authoriz
8686
### Basic Authentication
8787
In order to use the basic authentication functionality, turn in on from the application.properties file
8888
```
89-
basic.authentication.enabled=true
89+
petclinic.security.enable=true
9090
```
9191
This will secure all APIs and in order to access them, basic authentication is required.
9292
Apart from authentication, APIs also require authorization. This is done via roles that a user can have.
@@ -95,7 +95,7 @@ The existing roles are listed below with the corresponding permissions
9595
* VET_ADMIN -> PetTypeController, SpecialityController, VetController
9696
* ADMIN -> UserController
9797

98-
There is an existing user with the username admin and password admin that has access to all APIs.
98+
There is an existing user with the username `admin` and password `admin` that has access to all APIs.
9999
In order to add a new user, please use the following API:
100100
```
101101
POST /api/users
@@ -139,7 +139,7 @@ File -> Import -> Maven -> Existing Maven project
139139
|--|--|
140140
| REST API controllers | [REST folder](src/main/java/org/springframework/samples/petclinic/rest) |
141141
| Service | [ClinicServiceImpl.java](src/main/java/org/springframework/samples/petclinic/service/ClinicServiceImpl.java) |
142-
|JDBC | [jdbc folder](src/main/java/org/springframework/samples/petclinic/repository/jdb) |
142+
| JDBC | [jdbc folder](src/main/java/org/springframework/samples/petclinic/repository/jdbc) |
143143
| JPA | [jpa folder](src/main/java/org/springframework/samples/petclinic/repository/jpa) |
144144
| Spring Data JPA | [springdatajpa folder](src/main/java/org/springframework/samples/petclinic/repository/springdatajpa) |
145145
| Tests | [AbstractClinicServiceTests.java](src/test/java/org/springframework/samples/petclinic/service/AbstractClinicServiceTests.java) |

src/main/java/org/springframework/samples/petclinic/PetClinicApplication.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,10 @@
22

33
import org.springframework.boot.SpringApplication;
44
import org.springframework.boot.autoconfigure.SpringBootApplication;
5-
import org.springframework.boot.builder.SpringApplicationBuilder;
6-
import org.springframework.boot.web.support.SpringBootServletInitializer;
5+
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
76

87
@SpringBootApplication
98
public class PetClinicApplication extends SpringBootServletInitializer {
10-
11-
@Override
12-
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
13-
return application.sources(PetClinicApplication.class);
14-
}
159

1610
public static void main(String[] args) {
1711
SpringApplication.run(PetClinicApplication.class, args);

src/main/java/org/springframework/samples/petclinic/model/NamedEntity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import javax.persistence.Column;
1919
import javax.persistence.MappedSuperclass;
2020

21-
import org.hibernate.validator.constraints.NotEmpty;
21+
import javax.validation.constraints.NotEmpty;
2222

2323

2424
/**

src/main/java/org/springframework/samples/petclinic/model/Owner.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
import javax.persistence.OneToMany;
2929
import javax.persistence.Table;
3030
import javax.validation.constraints.Digits;
31+
import javax.validation.constraints.NotEmpty;
3132

32-
import org.hibernate.validator.constraints.NotEmpty;
3333
import org.springframework.beans.support.MutableSortDefinition;
3434
import org.springframework.beans.support.PropertyComparator;
3535
import org.springframework.core.style.ToStringCreator;

src/main/java/org/springframework/samples/petclinic/model/Person.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import javax.persistence.Column;
1919
import javax.persistence.MappedSuperclass;
2020

21-
import org.hibernate.validator.constraints.NotEmpty;
21+
import javax.validation.constraints.NotEmpty;
2222

2323
/**
2424
* Simple JavaBean domain object representing an person.

src/main/java/org/springframework/samples/petclinic/model/Visit.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
import javax.persistence.Temporal;
2626
import javax.persistence.TemporalType;
2727

28-
import org.hibernate.validator.constraints.NotEmpty;
28+
import javax.validation.constraints.NotEmpty;
2929
import org.springframework.format.annotation.DateTimeFormat;
3030
import org.springframework.samples.petclinic.rest.JacksonCustomVisitDeserializer;
3131
import org.springframework.samples.petclinic.rest.JacksonCustomVisitSerializer;

src/main/java/org/springframework/samples/petclinic/repository/jpa/JpaOwnerRepositoryImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
import org.springframework.context.annotation.Profile;
2525
import org.springframework.dao.DataAccessException;
26-
import org.springframework.orm.hibernate3.support.OpenSessionInViewFilter;
26+
import org.springframework.orm.hibernate5.support.OpenSessionInViewFilter;
2727
import org.springframework.samples.petclinic.model.Owner;
2828
import org.springframework.samples.petclinic.repository.OwnerRepository;
2929
import org.springframework.stereotype.Repository;
@@ -80,7 +80,7 @@ public void save(Owner owner) {
8080
}
8181

8282
}
83-
83+
8484
@SuppressWarnings("unchecked")
8585
@Override
8686
public Collection<Owner> findAll() throws DataAccessException {

src/main/java/org/springframework/samples/petclinic/repository/jpa/JpaPetTypeRepositoryImpl.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,17 +68,15 @@ public void save(PetType petType) throws DataAccessException {
6868
@Override
6969
public void delete(PetType petType) throws DataAccessException {
7070
this.em.remove(this.em.contains(petType) ? petType : this.em.merge(petType));
71-
String petTypeId = petType.getId().toString();
71+
Integer petTypeId = petType.getId();
7272

73-
List<Pet> pets = new ArrayList<Pet>();
74-
pets = this.em.createQuery("SELECT pet FROM Pet pet WHERE type_id=" + petTypeId).getResultList();
73+
List<Pet> pets = this.em.createQuery("SELECT pet FROM Pet pet WHERE type_id=" + petTypeId).getResultList();
7574
for (Pet pet : pets){
76-
List<Visit> visits = new ArrayList<Visit>();
77-
visits = pet.getVisits();
75+
List<Visit> visits = pet.getVisits();
7876
for (Visit visit : visits){
79-
this.em.createQuery("DELETE FROM Visit visit WHERE id=" + visit.getId().toString()).executeUpdate();
77+
this.em.createQuery("DELETE FROM Visit visit WHERE id=" + visit.getId()).executeUpdate();
8078
}
81-
this.em.createQuery("DELETE FROM Pet pet WHERE id=" + pet.getId().toString()).executeUpdate();
79+
this.em.createQuery("DELETE FROM Pet pet WHERE id=" + pet.getId()).executeUpdate();
8280
}
8381
this.em.createQuery("DELETE FROM PetType pettype WHERE id=" + petTypeId).executeUpdate();
8482
}

src/main/java/org/springframework/samples/petclinic/repository/jpa/JpaSpecialtyRepositoryImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public void save(Specialty specialty) throws DataAccessException {
6262
@Override
6363
public void delete(Specialty specialty) throws DataAccessException {
6464
this.em.remove(this.em.contains(specialty) ? specialty : this.em.merge(specialty));
65-
String specId = specialty.getId().toString();
65+
Integer specId = specialty.getId();
6666
this.em.createNativeQuery("DELETE FROM vet_specialties WHERE specialty_id=" + specId).executeUpdate();
6767
this.em.createQuery("DELETE FROM Specialty specialty WHERE id=" + specId).executeUpdate();
6868
}

0 commit comments

Comments
 (0)