From 8e446ae7218392af7a897fdcec82be6b1db49518 Mon Sep 17 00:00:00 2001 From: Antoine Rey Date: Sat, 6 Feb 2021 18:23:39 +0100 Subject: [PATCH 01/22] Complete Apache 2.0 license --- LICENSE | 208 +++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 198 insertions(+), 10 deletions(-) diff --git a/LICENSE b/LICENSE index 91ef974e0f..261eeb9e9f 100644 --- a/LICENSE +++ b/LICENSE @@ -1,13 +1,201 @@ -Copyright 2002-2020 the original author or authors. + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - http://www.apache.org/licenses/LICENSE-2.0 + 1. Definitions. -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. From b12d05b080e9333d862ebc6e2361cdd22b5a87e4 Mon Sep 17 00:00:00 2001 From: Antoine Rey Date: Sun, 28 Feb 2021 09:43:38 +0100 Subject: [PATCH 02/22] Upgrade to Spring Cloud 2020.0.1 (aka Ilford) and Spring Boot 2.4.2 (#173) --- pom.xml | 8 ++++---- spring-petclinic-admin-server/pom.xml | 8 ++++++-- .../src/main/resources/bootstrap.yml | 4 +++- spring-petclinic-api-gateway/pom.xml | 6 +++++- .../src/main/resources/bootstrap.yml | 4 +++- spring-petclinic-config-server/pom.xml | 6 +++++- .../src/test/resources/application.yml | 6 ++++++ spring-petclinic-customers-service/pom.xml | 6 +++++- .../src/main/resources/bootstrap.yml | 4 +++- spring-petclinic-discovery-server/pom.xml | 18 +++++------------- .../discovery/DiscoveryServerApplication.java | 2 +- .../src/main/resources/bootstrap.yml | 4 +++- spring-petclinic-vets-service/pom.xml | 6 +++++- .../src/main/resources/bootstrap.yml | 4 +++- spring-petclinic-visits-service/pom.xml | 6 +++++- .../src/main/resources/bootstrap.yml | 4 +++- 16 files changed, 65 insertions(+), 31 deletions(-) create mode 100644 spring-petclinic-config-server/src/test/resources/application.yml diff --git a/pom.xml b/pom.xml index 02b518cc23..88598252dd 100644 --- a/pom.xml +++ b/pom.xml @@ -6,12 +6,12 @@ org.springframework.boot spring-boot-starter-parent - 2.3.6.RELEASE + 2.4.2 org.springframework.samples spring-petclinic-microservices - 2.3.6 + 2.4.2 ${project.artifactId} pom @@ -29,8 +29,8 @@ 1.8 3.11.1 - 2.3.6.RELEASE - Hoxton.SR9 + 2.4.2 + 2020.0.1 2.22.0 diff --git a/spring-petclinic-admin-server/pom.xml b/spring-petclinic-admin-server/pom.xml index 5094e79145..4ccdc17afe 100644 --- a/spring-petclinic-admin-server/pom.xml +++ b/spring-petclinic-admin-server/pom.xml @@ -12,11 +12,11 @@ org.springframework.samples spring-petclinic-microservices - 2.3.6 + 2.4.2 - 2.2.2 + 2.3.1 9090 ${basedir}/../docker @@ -27,6 +27,10 @@ org.springframework.boot spring-boot-starter + + org.springframework.cloud + spring-cloud-starter-bootstrap + org.springframework.cloud spring-cloud-starter-config diff --git a/spring-petclinic-admin-server/src/main/resources/bootstrap.yml b/spring-petclinic-admin-server/src/main/resources/bootstrap.yml index acd7449356..d1ec2a8541 100644 --- a/spring-petclinic-admin-server/src/main/resources/bootstrap.yml +++ b/spring-petclinic-admin-server/src/main/resources/bootstrap.yml @@ -6,7 +6,9 @@ spring: name: admin-server --- spring: - profiles: docker + config: + activate: + on-profile: docker cloud: config: uri: http://config-server:8888 diff --git a/spring-petclinic-api-gateway/pom.xml b/spring-petclinic-api-gateway/pom.xml index 41e67b2126..0e9126ad2d 100644 --- a/spring-petclinic-api-gateway/pom.xml +++ b/spring-petclinic-api-gateway/pom.xml @@ -11,7 +11,7 @@ org.springframework.samples spring-petclinic-microservices - 2.3.6 + 2.4.2 @@ -53,6 +53,10 @@ org.springframework.cloud spring-cloud-sleuth-zipkin + + org.springframework.cloud + spring-cloud-starter-bootstrap + org.springframework.cloud spring-cloud-starter-circuitbreaker-reactor-resilience4j diff --git a/spring-petclinic-api-gateway/src/main/resources/bootstrap.yml b/spring-petclinic-api-gateway/src/main/resources/bootstrap.yml index f4cc782f9e..9aef7487e5 100644 --- a/spring-petclinic-api-gateway/src/main/resources/bootstrap.yml +++ b/spring-petclinic-api-gateway/src/main/resources/bootstrap.yml @@ -6,7 +6,9 @@ spring: name: api-gateway --- spring: - profiles: docker + config: + activate: + on-profile: docker cloud: config: uri: http://config-server:8888 diff --git a/spring-petclinic-config-server/pom.xml b/spring-petclinic-config-server/pom.xml index 0c28aee55e..737caf812b 100644 --- a/spring-petclinic-config-server/pom.xml +++ b/spring-petclinic-config-server/pom.xml @@ -11,7 +11,7 @@ org.springframework.samples spring-petclinic-microservices - 2.3.6 + 2.4.2 @@ -32,6 +32,10 @@ org.springframework.cloud spring-cloud-config-server + + org.springframework.cloud + spring-cloud-starter-bootstrap + diff --git a/spring-petclinic-config-server/src/test/resources/application.yml b/spring-petclinic-config-server/src/test/resources/application.yml new file mode 100644 index 0000000000..b4fb9c744c --- /dev/null +++ b/spring-petclinic-config-server/src/test/resources/application.yml @@ -0,0 +1,6 @@ +spring: + cloud: + config: + server: + git: + uri: https://github.com/spring-petclinic/spring-petclinic-microservices-config diff --git a/spring-petclinic-customers-service/pom.xml b/spring-petclinic-customers-service/pom.xml index ac198f1235..de578ac6de 100644 --- a/spring-petclinic-customers-service/pom.xml +++ b/spring-petclinic-customers-service/pom.xml @@ -11,7 +11,7 @@ org.springframework.samples spring-petclinic-microservices - 2.3.6 + 2.4.2 @@ -41,6 +41,10 @@ + + org.springframework.cloud + spring-cloud-starter-bootstrap + org.springframework.cloud spring-cloud-starter-config diff --git a/spring-petclinic-customers-service/src/main/resources/bootstrap.yml b/spring-petclinic-customers-service/src/main/resources/bootstrap.yml index c0f6dca616..58281a4441 100644 --- a/spring-petclinic-customers-service/src/main/resources/bootstrap.yml +++ b/spring-petclinic-customers-service/src/main/resources/bootstrap.yml @@ -6,7 +6,9 @@ spring: name: customers-service --- spring: - profiles: docker + config: + activate: + on-profile: docker cloud: config: uri: http://config-server:8888 diff --git a/spring-petclinic-discovery-server/pom.xml b/spring-petclinic-discovery-server/pom.xml index 2efabd77f2..a6ca05cc13 100644 --- a/spring-petclinic-discovery-server/pom.xml +++ b/spring-petclinic-discovery-server/pom.xml @@ -11,7 +11,7 @@ org.springframework.samples spring-petclinic-microservices - 2.3.6 + 2.4.2 @@ -30,23 +30,15 @@ org.springframework.cloud - spring-cloud-starter-config + spring-cloud-starter-bootstrap org.springframework.cloud - spring-cloud-starter-netflix-eureka-server - - - - - org.junit.jupiter - junit-jupiter-api - test + spring-cloud-starter-config - org.junit.jupiter - junit-jupiter-engine - test + org.springframework.cloud + spring-cloud-starter-netflix-eureka-server diff --git a/spring-petclinic-discovery-server/src/main/java/org/springframework/samples/petclinic/discovery/DiscoveryServerApplication.java b/spring-petclinic-discovery-server/src/main/java/org/springframework/samples/petclinic/discovery/DiscoveryServerApplication.java index 59e2c33961..6c2d281ec7 100644 --- a/spring-petclinic-discovery-server/src/main/java/org/springframework/samples/petclinic/discovery/DiscoveryServerApplication.java +++ b/spring-petclinic-discovery-server/src/main/java/org/springframework/samples/petclinic/discovery/DiscoveryServerApplication.java @@ -22,8 +22,8 @@ /** * @author Maciej Szarlinski */ -@EnableEurekaServer @SpringBootApplication +@EnableEurekaServer public class DiscoveryServerApplication { public static void main(String[] args) { diff --git a/spring-petclinic-discovery-server/src/main/resources/bootstrap.yml b/spring-petclinic-discovery-server/src/main/resources/bootstrap.yml index 9c07ca22b5..eba87c89e9 100644 --- a/spring-petclinic-discovery-server/src/main/resources/bootstrap.yml +++ b/spring-petclinic-discovery-server/src/main/resources/bootstrap.yml @@ -6,7 +6,9 @@ spring: name: discovery-server --- spring: - profiles: docker + config: + activate: + on-profile: docker cloud: config: uri: http://config-server:8888 diff --git a/spring-petclinic-vets-service/pom.xml b/spring-petclinic-vets-service/pom.xml index 7b14f16f52..570452cb35 100644 --- a/spring-petclinic-vets-service/pom.xml +++ b/spring-petclinic-vets-service/pom.xml @@ -11,7 +11,7 @@ org.springframework.samples spring-petclinic-microservices - 2.3.6 + 2.4.2 @@ -53,6 +53,10 @@ org.springframework.cloud spring-cloud-sleuth-zipkin + + org.springframework.cloud + spring-cloud-starter-bootstrap + org.springframework.cloud spring-cloud-starter-config diff --git a/spring-petclinic-vets-service/src/main/resources/bootstrap.yml b/spring-petclinic-vets-service/src/main/resources/bootstrap.yml index 59c6dd2588..bc2f683e5e 100644 --- a/spring-petclinic-vets-service/src/main/resources/bootstrap.yml +++ b/spring-petclinic-vets-service/src/main/resources/bootstrap.yml @@ -6,7 +6,9 @@ spring: name: vets-service --- spring: - profiles: docker + config: + activate: + on-profile: docker cloud: config: uri: http://config-server:8888 diff --git a/spring-petclinic-visits-service/pom.xml b/spring-petclinic-visits-service/pom.xml index e7c4958589..670acbe68d 100644 --- a/spring-petclinic-visits-service/pom.xml +++ b/spring-petclinic-visits-service/pom.xml @@ -11,7 +11,7 @@ org.springframework.samples spring-petclinic-microservices - 2.3.6 + 2.4.2 @@ -40,6 +40,10 @@ + + org.springframework.cloud + spring-cloud-starter-bootstrap + org.springframework.cloud spring-cloud-starter-config diff --git a/spring-petclinic-visits-service/src/main/resources/bootstrap.yml b/spring-petclinic-visits-service/src/main/resources/bootstrap.yml index 1ddd133b1e..92f4fcae36 100644 --- a/spring-petclinic-visits-service/src/main/resources/bootstrap.yml +++ b/spring-petclinic-visits-service/src/main/resources/bootstrap.yml @@ -6,7 +6,9 @@ spring: name: visits-service --- spring: - profiles: docker + config: + activate: + on-profile: docker cloud: config: uri: http://config-server:8888 From 1f8191d5f6eb07d73f207173fa2a4eb19012edcb Mon Sep 17 00:00:00 2001 From: Marcin Grzejszczak Date: Tue, 20 Apr 2021 08:28:01 +0000 Subject: [PATCH 03/22] Added chaos monkey setup (#177) * Added chaos monkey setup * Update scripts/chaos/call_chaos.sh Co-authored-by: Jonatan Ivanov * Added docs Co-authored-by: Jonatan Ivanov --- .gitignore | 3 + README.md | 6 + pom.xml | 6 + scripts/chaos/README.md | 24 +++ scripts/chaos/attacks_disable.json | 6 + scripts/chaos/attacks_enable_exception.json | 4 + .../chaos/attacks_enable_killapplication.json | 3 + scripts/chaos/attacks_enable_latency.json | 5 + scripts/chaos/attacks_enable_memory.json | 4 + scripts/chaos/call_chaos.sh | 49 ++++++ scripts/chaos/watcher_disable.json | 7 + scripts/chaos/watcher_enable_component.json | 3 + scripts/chaos/watcher_enable_controller.json | 3 + scripts/chaos/watcher_enable_repository.json | 3 + .../chaos/watcher_enable_restcontroller.json | 3 + scripts/chaos/watcher_enable_service.json | 3 + scripts/run_all.sh | 29 +++ spring-petclinic-api-gateway/.factorypath | 159 ----------------- spring-petclinic-customers-service/pom.xml | 4 + spring-petclinic-vets-service/.factorypath | 166 ------------------ spring-petclinic-vets-service/pom.xml | 4 + spring-petclinic-visits-service/pom.xml | 4 + 22 files changed, 173 insertions(+), 325 deletions(-) create mode 100644 scripts/chaos/README.md create mode 100644 scripts/chaos/attacks_disable.json create mode 100644 scripts/chaos/attacks_enable_exception.json create mode 100644 scripts/chaos/attacks_enable_killapplication.json create mode 100644 scripts/chaos/attacks_enable_latency.json create mode 100644 scripts/chaos/attacks_enable_memory.json create mode 100755 scripts/chaos/call_chaos.sh create mode 100644 scripts/chaos/watcher_disable.json create mode 100644 scripts/chaos/watcher_enable_component.json create mode 100644 scripts/chaos/watcher_enable_controller.json create mode 100644 scripts/chaos/watcher_enable_repository.json create mode 100644 scripts/chaos/watcher_enable_restcontroller.json create mode 100644 scripts/chaos/watcher_enable_service.json create mode 100755 scripts/run_all.sh delete mode 100644 spring-petclinic-api-gateway/.factorypath delete mode 100644 spring-petclinic-vets-service/.factorypath diff --git a/.gitignore b/.gitignore index 3b29741b01..e282e3b238 100644 --- a/.gitignore +++ b/.gitignore @@ -14,5 +14,8 @@ target/ .idea *.iml +# Visual Studio Code +.factorypath + # Branch switching generated/ diff --git a/README.md b/README.md index 2812b8ea02..6e1a26724c 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,12 @@ The `master` branch uses an Alpine linux with JRE 8 as Docker base. You will f *NOTE: Under MacOSX or Windows, make sure that the Docker VM has enough memory to run the microservices. The default settings are usually not enough and make the `docker-compose up` painfully slow.* + +## Starting services locally with docker-compose and Java +If you experience issues with running the system via docker-compose you can try running the `./scripts/run_all.sh` script that will start the infrastructure services via docker-compose and all the Java based applications via standard `nohup java -jar ...` command. The logs will be available under `${ROOT}/target/nameoftheapp.log`. + +Each of the java based applications is started with the `chaos-monkey` profile in order to interact with Spring Boot Chaos Monkey. You can check out the (README)[scripts/chaos/README.md] for more information about how to use the `./scripts/chaos/call_chaos.sh` helper script to enable assaults. + ## Understanding the Spring Petclinic application [See the presentation of the Spring Petclinic Framework version](http://fr.slideshare.net/AntoineRey/spring-framework-petclinic-sample-application) diff --git a/pom.xml b/pom.xml index 88598252dd..8c5f791a3f 100644 --- a/pom.xml +++ b/pom.xml @@ -31,6 +31,7 @@ 2.4.2 2020.0.1 + 2.3.2 2.22.0 @@ -62,6 +63,11 @@ + + de.codecentric + chaos-monkey-spring-boot + ${chaos-monkey-spring-boot.version} + org.assertj assertj-core diff --git a/scripts/chaos/README.md b/scripts/chaos/README.md new file mode 100644 index 0000000000..e7bbc9ed3b --- /dev/null +++ b/scripts/chaos/README.md @@ -0,0 +1,24 @@ +# Spring Boot Chaos Monkey Scripts + +You can read more about the possible configuration options [here](https://codecentric.github.io/chaos-monkey-spring-boot/latest/#_properties). + +## Scripts + +In order to active Spring Boot Chaos Monkey's assault options and component instrumentation, you need to call the project's API. For your convenience we're providing a script that turns on various watchers and attacks. To print out the usage description just call the script without any parameters. + +```bash +$ ./scripts/chaos/call_chaos.sh +usage: ./scripts/chaos/call_chaos.sh: +First pick either customers, visits or vets +Then pick what to enable. Order matters! +Example +./scripts/chaos/call_chaos.sh visits attacks_enable_exception watcher_enable_restcontroller +``` + +The script takes in at minimum 2 parameters. First provides the name of the application for which you want to turn on Chaos Monkey features. The subsequent ones will enable attacks and watchers. The name of the desired feature maps to a json file that gets updated to `http://localhost:${PORT}/actuator/chaosmonkey/assaults` and `http://localhost:${PORT}/actuator/chaosmonkey/watchers` respectively. Example of enabling exception assault via rest controllers for the visits microservice: + +```bash +$ ./scripts/chaos/call_chaos.sh visits attacks_enable_exception watcher_enable_restcontroller +``` + +The default assault configuration is set to fail every 5th request. That means that the first four will work as if Chaos Monkey was be disabled. diff --git a/scripts/chaos/attacks_disable.json b/scripts/chaos/attacks_disable.json new file mode 100644 index 0000000000..cc60dbf86a --- /dev/null +++ b/scripts/chaos/attacks_disable.json @@ -0,0 +1,6 @@ +{ + "latencyActive": false, + "exceptionsActive": false, + "killApplicationActive": false, + "memoryActive": false +} diff --git a/scripts/chaos/attacks_enable_exception.json b/scripts/chaos/attacks_enable_exception.json new file mode 100644 index 0000000000..4e24f5a149 --- /dev/null +++ b/scripts/chaos/attacks_enable_exception.json @@ -0,0 +1,4 @@ +{ + "exceptionsActive": true, + "level" : 5 +} diff --git a/scripts/chaos/attacks_enable_killapplication.json b/scripts/chaos/attacks_enable_killapplication.json new file mode 100644 index 0000000000..ab67208537 --- /dev/null +++ b/scripts/chaos/attacks_enable_killapplication.json @@ -0,0 +1,3 @@ +{ + "killApplicationActive": true +} diff --git a/scripts/chaos/attacks_enable_latency.json b/scripts/chaos/attacks_enable_latency.json new file mode 100644 index 0000000000..1ef154608f --- /dev/null +++ b/scripts/chaos/attacks_enable_latency.json @@ -0,0 +1,5 @@ +{ + "latencyActive": true, + "latencyRangeStart" : 1000, + "latencyRangeEnd" : 10000 +} diff --git a/scripts/chaos/attacks_enable_memory.json b/scripts/chaos/attacks_enable_memory.json new file mode 100644 index 0000000000..b920663932 --- /dev/null +++ b/scripts/chaos/attacks_enable_memory.json @@ -0,0 +1,4 @@ +{ + "memoryActive": true, + "level" : 5 +} diff --git a/scripts/chaos/call_chaos.sh b/scripts/chaos/call_chaos.sh new file mode 100755 index 0000000000..b412427e24 --- /dev/null +++ b/scripts/chaos/call_chaos.sh @@ -0,0 +1,49 @@ +#!/usr/bin/env bash + +set -o errexit +set -o errtrace +set -o nounset +set -o pipefail + +ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +function usage { + echo "usage: $0: " + echo "First pick either customers, visits or vets" + echo "Then pick what to enable. Order matters!" + echo "Example" + echo "./scripts/chaos/call_chaos.sh visits attacks_enable_exception watcher_enable_restcontroller" + exit 1 +} + +if [[ $# -lt 2 ]]; then + usage +fi + +export PORT="${PORT:-}" + +while [[ $# > 0 ]] +do +key="$1" +case $1 in + customers) + PORT=8081 + ;; + visits) + PORT=8082 + ;; + vets) + PORT=8083 + ;; + attacks*) + ( cd "${ROOT_DIR}" && curl "http://localhost:${PORT}/actuator/chaosmonkey/assaults" -H "Content-Type: application/json" --data @"${1}".json --fail ) + ;; + watcher*) + ( cd "${ROOT_DIR}" && curl "http://localhost:${PORT}/actuator/chaosmonkey/watchers" -H "Content-Type: application/json" --data @"${1}".json --fail ) + ;; + *) + usage + ;; +esac +shift +done diff --git a/scripts/chaos/watcher_disable.json b/scripts/chaos/watcher_disable.json new file mode 100644 index 0000000000..78779dc6b2 --- /dev/null +++ b/scripts/chaos/watcher_disable.json @@ -0,0 +1,7 @@ +{ + "controller": false, + "restController": false, + "service": false, + "repository": false, + "component": false +} diff --git a/scripts/chaos/watcher_enable_component.json b/scripts/chaos/watcher_enable_component.json new file mode 100644 index 0000000000..10e7f9d584 --- /dev/null +++ b/scripts/chaos/watcher_enable_component.json @@ -0,0 +1,3 @@ +{ + "component": true +} diff --git a/scripts/chaos/watcher_enable_controller.json b/scripts/chaos/watcher_enable_controller.json new file mode 100644 index 0000000000..b45401627d --- /dev/null +++ b/scripts/chaos/watcher_enable_controller.json @@ -0,0 +1,3 @@ +{ + "controller": true +} diff --git a/scripts/chaos/watcher_enable_repository.json b/scripts/chaos/watcher_enable_repository.json new file mode 100644 index 0000000000..5e16469c38 --- /dev/null +++ b/scripts/chaos/watcher_enable_repository.json @@ -0,0 +1,3 @@ +{ + "repository": true +} diff --git a/scripts/chaos/watcher_enable_restcontroller.json b/scripts/chaos/watcher_enable_restcontroller.json new file mode 100644 index 0000000000..e846f6d6db --- /dev/null +++ b/scripts/chaos/watcher_enable_restcontroller.json @@ -0,0 +1,3 @@ +{ + "restController": true +} diff --git a/scripts/chaos/watcher_enable_service.json b/scripts/chaos/watcher_enable_service.json new file mode 100644 index 0000000000..f4dd8e7de9 --- /dev/null +++ b/scripts/chaos/watcher_enable_service.json @@ -0,0 +1,3 @@ +{ + "service": true +} diff --git a/scripts/run_all.sh b/scripts/run_all.sh new file mode 100755 index 0000000000..8560c917e6 --- /dev/null +++ b/scripts/run_all.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash + +set -o errexit +set -o errtrace +set -o nounset +set -o pipefail + +pkill -9 -f spring-petclinic || echo "Failed to kill any apps" + +docker-compose kill || echo "No docker containers are running" + +echo "Running infra" +docker-compose up -d grafana-server prometheus-server tracing-server + +echo "Running apps" +mkdir -p target +nohup java -jar spring-petclinic-config-server/target/*.jar --server.port=8888 --spring.profiles.active=chaos-monkey > target/config-server.log 2>&1 & +echo "Waiting for config server to start" +sleep 20 +nohup java -jar spring-petclinic-discovery-server/target/*.jar --server.port=8761 --spring.profiles.active=chaos-monkey > target/discovery-server.log 2>&1 & +echo "Waiting for discovery server to start" +sleep 20 +nohup java -jar spring-petclinic-customers-service/target/*.jar --server.port=8081 --spring.profiles.active=chaos-monkey > target/customers-service.log 2>&1 & +nohup java -jar spring-petclinic-visits-service/target/*.jar --server.port=8082 --spring.profiles.active=chaos-monkey > target/visits-service.log 2>&1 & +nohup java -jar spring-petclinic-vets-service/target/*.jar --server.port=8083 --spring.profiles.active=chaos-monkey > target/vets-service.log 2>&1 & +nohup java -jar spring-petclinic-api-gateway/target/*.jar --server.port=8080 --spring.profiles.active=chaos-monkey > target/gateway-service.log 2>&1 & +nohup java -jar spring-petclinic-admin-server/target/*.jar --server.port=9090 --spring.profiles.active=chaos-monkey > target/admin-server.log 2>&1 & +echo "Waiting for apps to start" +sleep 60 diff --git a/spring-petclinic-api-gateway/.factorypath b/spring-petclinic-api-gateway/.factorypath deleted file mode 100644 index 29bf92844b..0000000000 --- a/spring-petclinic-api-gateway/.factorypath +++ /dev/null @@ -1,159 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/spring-petclinic-customers-service/pom.xml b/spring-petclinic-customers-service/pom.xml index de578ac6de..758c172024 100644 --- a/spring-petclinic-customers-service/pom.xml +++ b/spring-petclinic-customers-service/pom.xml @@ -85,6 +85,10 @@ io.micrometer micrometer-registry-prometheus + + de.codecentric + chaos-monkey-spring-boot + diff --git a/spring-petclinic-vets-service/.factorypath b/spring-petclinic-vets-service/.factorypath deleted file mode 100644 index ccb3d4aae0..0000000000 --- a/spring-petclinic-vets-service/.factorypath +++ /dev/null @@ -1,166 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/spring-petclinic-vets-service/pom.xml b/spring-petclinic-vets-service/pom.xml index 570452cb35..4f6baa129e 100644 --- a/spring-petclinic-vets-service/pom.xml +++ b/spring-petclinic-vets-service/pom.xml @@ -101,6 +101,10 @@ io.micrometer micrometer-registry-prometheus + + de.codecentric + chaos-monkey-spring-boot + diff --git a/spring-petclinic-visits-service/pom.xml b/spring-petclinic-visits-service/pom.xml index 670acbe68d..275bbbb31d 100644 --- a/spring-petclinic-visits-service/pom.xml +++ b/spring-petclinic-visits-service/pom.xml @@ -84,6 +84,10 @@ io.micrometer micrometer-registry-prometheus + + de.codecentric + chaos-monkey-spring-boot + From 101ffbdf13a0f1f5a42713f88f83fb0fda0849f5 Mon Sep 17 00:00:00 2001 From: Antoine Rey Date: Thu, 6 May 2021 19:14:10 +0200 Subject: [PATCH 04/22] Do not fail packaging if repo info is absent #91 Try to fix the Maven issue references in #91 --- pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/pom.xml b/pom.xml index 8c5f791a3f..031ebbccef 100644 --- a/pom.xml +++ b/pom.xml @@ -136,6 +136,7 @@ ${project.build.outputDirectory}/git.properties false + false From 73da0b0e897ab091bff5f0640c215aeee69449cb Mon Sep 17 00:00:00 2001 From: Jonatan Ivanov Date: Sat, 8 May 2021 02:14:01 -0700 Subject: [PATCH 05/22] Bump Spring Cloud version to 2020.0.2 and Spring Boot version to 2.4.5 #178 --- pom.xml | 51 +++------------------- spring-petclinic-admin-server/pom.xml | 2 +- spring-petclinic-api-gateway/pom.xml | 28 ++---------- spring-petclinic-customers-service/pom.xml | 1 + spring-petclinic-vets-service/pom.xml | 1 + spring-petclinic-visits-service/pom.xml | 1 + 6 files changed, 13 insertions(+), 71 deletions(-) diff --git a/pom.xml b/pom.xml index 031ebbccef..4f95f78791 100644 --- a/pom.xml +++ b/pom.xml @@ -27,13 +27,11 @@ 1.8 - 3.11.1 + 3.17.1 - 2.4.2 - 2020.0.1 - 2.3.2 - - 2.22.0 + 2.4.5 + 2020.0.2 + 2.3.10 springcommunity 9090 @@ -51,18 +49,6 @@ pom import - - org.springframework.boot - spring-boot-starter-test - ${spring-boot.version} - test - - - org.junit.vintage - junit-vintage-engine - - - de.codecentric chaos-monkey-spring-boot @@ -74,11 +60,9 @@ ${assertj.version} test - - springboot @@ -133,15 +117,13 @@ true yyyy-MM-dd'T'HH:mm:ssZ true - ${project.build.outputDirectory}/git.properties - + ${project.build.outputDirectory}/git.properties false false - @@ -185,27 +167,4 @@ - - - - spring-milestones - Spring Milestones - https://repo.spring.io/milestone - - false - - - - - - - spring-milestones - Spring Milestones - https://repo.spring.io/milestone - - false - - - - diff --git a/spring-petclinic-admin-server/pom.xml b/spring-petclinic-admin-server/pom.xml index 4ccdc17afe..bf08201245 100644 --- a/spring-petclinic-admin-server/pom.xml +++ b/spring-petclinic-admin-server/pom.xml @@ -16,7 +16,7 @@ - 2.3.1 + 2.4.1 9090 ${basedir}/../docker diff --git a/spring-petclinic-api-gateway/pom.xml b/spring-petclinic-api-gateway/pom.xml index 0e9126ad2d..0e696fbaff 100644 --- a/spring-petclinic-api-gateway/pom.xml +++ b/spring-petclinic-api-gateway/pom.xml @@ -16,17 +16,15 @@ 3.3.7-1 - 1.11.4 - 3.1.1-1 - 1.6.4 - 1.0.3 + 3.6.0 + 1.8.2 + 1.0.20 1.8.0 8081 ${basedir}/../docker - org.springframework.boot @@ -68,24 +66,6 @@ org.springframework.cloud spring-cloud-starter-netflix-eureka-client - - - org.springframework.cloud - spring-cloud-starter-netflix-ribbon - - - org.springframework.cloud - spring-cloud-netflix-ribbon - - - com.netflix.ribbon - ribbon-eureka - - - org.springframework.cloud - spring-cloud-netflix-hystrix - - org.springframework.cloud @@ -104,6 +84,7 @@ org.projectlombok lombok + provided io.micrometer @@ -211,5 +192,4 @@ - diff --git a/spring-petclinic-customers-service/pom.xml b/spring-petclinic-customers-service/pom.xml index 758c172024..653108c5e3 100644 --- a/spring-petclinic-customers-service/pom.xml +++ b/spring-petclinic-customers-service/pom.xml @@ -80,6 +80,7 @@ org.projectlombok lombok + provided io.micrometer diff --git a/spring-petclinic-vets-service/pom.xml b/spring-petclinic-vets-service/pom.xml index 4f6baa129e..e91403c269 100644 --- a/spring-petclinic-vets-service/pom.xml +++ b/spring-petclinic-vets-service/pom.xml @@ -74,6 +74,7 @@ org.projectlombok lombok + provided javax.cache diff --git a/spring-petclinic-visits-service/pom.xml b/spring-petclinic-visits-service/pom.xml index 275bbbb31d..f451c60043 100644 --- a/spring-petclinic-visits-service/pom.xml +++ b/spring-petclinic-visits-service/pom.xml @@ -65,6 +65,7 @@ org.projectlombok lombok + provided org.hsqldb From 8818cc95ad0c0025df51119758feee4d878bbc23 Mon Sep 17 00:00:00 2001 From: Jonatan Ivanov Date: Sun, 9 May 2021 02:26:11 -0700 Subject: [PATCH 06/22] Bump up version to 2.4.5 (#179) also fixing spring-boot-starter-parent version --- pom.xml | 4 ++-- spring-petclinic-admin-server/pom.xml | 2 +- spring-petclinic-api-gateway/pom.xml | 2 +- spring-petclinic-config-server/pom.xml | 2 +- spring-petclinic-customers-service/pom.xml | 2 +- spring-petclinic-discovery-server/pom.xml | 2 +- spring-petclinic-vets-service/pom.xml | 2 +- spring-petclinic-visits-service/pom.xml | 2 +- 8 files changed, 9 insertions(+), 9 deletions(-) diff --git a/pom.xml b/pom.xml index 4f95f78791..87b7d8cb6e 100644 --- a/pom.xml +++ b/pom.xml @@ -6,12 +6,12 @@ org.springframework.boot spring-boot-starter-parent - 2.4.2 + 2.4.5 org.springframework.samples spring-petclinic-microservices - 2.4.2 + 2.4.5 ${project.artifactId} pom diff --git a/spring-petclinic-admin-server/pom.xml b/spring-petclinic-admin-server/pom.xml index bf08201245..499781e74f 100644 --- a/spring-petclinic-admin-server/pom.xml +++ b/spring-petclinic-admin-server/pom.xml @@ -12,7 +12,7 @@ org.springframework.samples spring-petclinic-microservices - 2.4.2 + 2.4.5 diff --git a/spring-petclinic-api-gateway/pom.xml b/spring-petclinic-api-gateway/pom.xml index 0e696fbaff..61ad618cd9 100644 --- a/spring-petclinic-api-gateway/pom.xml +++ b/spring-petclinic-api-gateway/pom.xml @@ -11,7 +11,7 @@ org.springframework.samples spring-petclinic-microservices - 2.4.2 + 2.4.5 diff --git a/spring-petclinic-config-server/pom.xml b/spring-petclinic-config-server/pom.xml index 737caf812b..3fd7ca9681 100644 --- a/spring-petclinic-config-server/pom.xml +++ b/spring-petclinic-config-server/pom.xml @@ -11,7 +11,7 @@ org.springframework.samples spring-petclinic-microservices - 2.4.2 + 2.4.5 diff --git a/spring-petclinic-customers-service/pom.xml b/spring-petclinic-customers-service/pom.xml index 653108c5e3..8c6b93c5c7 100644 --- a/spring-petclinic-customers-service/pom.xml +++ b/spring-petclinic-customers-service/pom.xml @@ -11,7 +11,7 @@ org.springframework.samples spring-petclinic-microservices - 2.4.2 + 2.4.5 diff --git a/spring-petclinic-discovery-server/pom.xml b/spring-petclinic-discovery-server/pom.xml index a6ca05cc13..74d5c26a48 100644 --- a/spring-petclinic-discovery-server/pom.xml +++ b/spring-petclinic-discovery-server/pom.xml @@ -11,7 +11,7 @@ org.springframework.samples spring-petclinic-microservices - 2.4.2 + 2.4.5 diff --git a/spring-petclinic-vets-service/pom.xml b/spring-petclinic-vets-service/pom.xml index e91403c269..dfbde74bc9 100644 --- a/spring-petclinic-vets-service/pom.xml +++ b/spring-petclinic-vets-service/pom.xml @@ -11,7 +11,7 @@ org.springframework.samples spring-petclinic-microservices - 2.4.2 + 2.4.5 diff --git a/spring-petclinic-visits-service/pom.xml b/spring-petclinic-visits-service/pom.xml index f451c60043..87df568c47 100644 --- a/spring-petclinic-visits-service/pom.xml +++ b/spring-petclinic-visits-service/pom.xml @@ -11,7 +11,7 @@ org.springframework.samples spring-petclinic-microservices - 2.4.2 + 2.4.5 From 7259a82a53cfbf405276befd3c25d78707dcd51b Mon Sep 17 00:00:00 2001 From: Antoine Rey Date: Sat, 10 Jul 2021 12:20:03 +0200 Subject: [PATCH 07/22] Upgrade to Spring Cloud 2020.0.2 and Spring Boot 2.5.1 (#181) --- pom.xml | 8 ++++---- spring-petclinic-admin-server/pom.xml | 2 +- spring-petclinic-api-gateway/pom.xml | 2 +- .../web/ApiGatewayControllerTest.java | 2 +- .../web/CircuitBreakerConfiguration.java | 20 +++++++++++++++++++ spring-petclinic-config-server/pom.xml | 2 +- spring-petclinic-customers-service/pom.xml | 2 +- spring-petclinic-discovery-server/pom.xml | 2 +- spring-petclinic-vets-service/pom.xml | 2 +- spring-petclinic-visits-service/pom.xml | 2 +- 10 files changed, 32 insertions(+), 12 deletions(-) create mode 100644 spring-petclinic-api-gateway/src/test/java/org/springframework/samples/petclinic/api/boundary/web/CircuitBreakerConfiguration.java diff --git a/pom.xml b/pom.xml index 87b7d8cb6e..c2c8d2f787 100644 --- a/pom.xml +++ b/pom.xml @@ -6,12 +6,12 @@ org.springframework.boot spring-boot-starter-parent - 2.4.5 + 2.5.1 org.springframework.samples spring-petclinic-microservices - 2.4.5 + 2.5.1 ${project.artifactId} pom @@ -29,8 +29,8 @@ 1.8 3.17.1 - 2.4.5 - 2020.0.2 + 2.5.1 + 2020.0.3 2.3.10 springcommunity diff --git a/spring-petclinic-admin-server/pom.xml b/spring-petclinic-admin-server/pom.xml index 499781e74f..951bff91d8 100644 --- a/spring-petclinic-admin-server/pom.xml +++ b/spring-petclinic-admin-server/pom.xml @@ -12,7 +12,7 @@ org.springframework.samples spring-petclinic-microservices - 2.4.5 + 2.5.1 diff --git a/spring-petclinic-api-gateway/pom.xml b/spring-petclinic-api-gateway/pom.xml index 61ad618cd9..3bc2f6147c 100644 --- a/spring-petclinic-api-gateway/pom.xml +++ b/spring-petclinic-api-gateway/pom.xml @@ -11,7 +11,7 @@ org.springframework.samples spring-petclinic-microservices - 2.4.5 + 2.5.1 diff --git a/spring-petclinic-api-gateway/src/test/java/org/springframework/samples/petclinic/api/boundary/web/ApiGatewayControllerTest.java b/spring-petclinic-api-gateway/src/test/java/org/springframework/samples/petclinic/api/boundary/web/ApiGatewayControllerTest.java index 9f5707e681..f7ca84d4e1 100644 --- a/spring-petclinic-api-gateway/src/test/java/org/springframework/samples/petclinic/api/boundary/web/ApiGatewayControllerTest.java +++ b/spring-petclinic-api-gateway/src/test/java/org/springframework/samples/petclinic/api/boundary/web/ApiGatewayControllerTest.java @@ -23,7 +23,7 @@ @ExtendWith(SpringExtension.class) @WebFluxTest(controllers = ApiGatewayController.class) -@Import(ReactiveResilience4JAutoConfiguration.class) +@Import({ReactiveResilience4JAutoConfiguration.class, CircuitBreakerConfiguration.class}) class ApiGatewayControllerTest { @MockBean diff --git a/spring-petclinic-api-gateway/src/test/java/org/springframework/samples/petclinic/api/boundary/web/CircuitBreakerConfiguration.java b/spring-petclinic-api-gateway/src/test/java/org/springframework/samples/petclinic/api/boundary/web/CircuitBreakerConfiguration.java new file mode 100644 index 0000000000..4fe17d0b82 --- /dev/null +++ b/spring-petclinic-api-gateway/src/test/java/org/springframework/samples/petclinic/api/boundary/web/CircuitBreakerConfiguration.java @@ -0,0 +1,20 @@ +package org.springframework.samples.petclinic.api.boundary.web; + +import io.github.resilience4j.circuitbreaker.CircuitBreakerRegistry; +import io.github.resilience4j.timelimiter.TimeLimiterRegistry; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class CircuitBreakerConfiguration { + + @Bean + public CircuitBreakerRegistry circuitBreakerRegistry() { + return CircuitBreakerRegistry.ofDefaults(); + } + + @Bean + public TimeLimiterRegistry timeLimiterRegistry() { + return TimeLimiterRegistry.ofDefaults(); + } +} diff --git a/spring-petclinic-config-server/pom.xml b/spring-petclinic-config-server/pom.xml index 3fd7ca9681..ef45071e88 100644 --- a/spring-petclinic-config-server/pom.xml +++ b/spring-petclinic-config-server/pom.xml @@ -11,7 +11,7 @@ org.springframework.samples spring-petclinic-microservices - 2.4.5 + 2.5.1 diff --git a/spring-petclinic-customers-service/pom.xml b/spring-petclinic-customers-service/pom.xml index 8c6b93c5c7..2bd021d6b4 100644 --- a/spring-petclinic-customers-service/pom.xml +++ b/spring-petclinic-customers-service/pom.xml @@ -11,7 +11,7 @@ org.springframework.samples spring-petclinic-microservices - 2.4.5 + 2.5.1 diff --git a/spring-petclinic-discovery-server/pom.xml b/spring-petclinic-discovery-server/pom.xml index 74d5c26a48..f08859f303 100644 --- a/spring-petclinic-discovery-server/pom.xml +++ b/spring-petclinic-discovery-server/pom.xml @@ -11,7 +11,7 @@ org.springframework.samples spring-petclinic-microservices - 2.4.5 + 2.5.1 diff --git a/spring-petclinic-vets-service/pom.xml b/spring-petclinic-vets-service/pom.xml index dfbde74bc9..06ff6cd534 100644 --- a/spring-petclinic-vets-service/pom.xml +++ b/spring-petclinic-vets-service/pom.xml @@ -11,7 +11,7 @@ org.springframework.samples spring-petclinic-microservices - 2.4.5 + 2.5.1 diff --git a/spring-petclinic-visits-service/pom.xml b/spring-petclinic-visits-service/pom.xml index 87df568c47..2268234e08 100644 --- a/spring-petclinic-visits-service/pom.xml +++ b/spring-petclinic-visits-service/pom.xml @@ -11,7 +11,7 @@ org.springframework.samples spring-petclinic-microservices - 2.4.5 + 2.5.1 From 8af5e01129832b430877b91d2098b932b9b3708f Mon Sep 17 00:00:00 2001 From: Antoine Rey Date: Fri, 22 Oct 2021 19:21:57 +0200 Subject: [PATCH 08/22] Migrate from Travis CI to GitHub actions (#187) * Use Github Actions for CI * Change Travis Badge to Github Actions one --- .github/workflows/maven-build.yml | 26 ++++++++++++++++++++++++++ README.md | 3 ++- 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/maven-build.yml diff --git a/.github/workflows/maven-build.yml b/.github/workflows/maven-build.yml new file mode 100644 index 0000000000..b2099fb2ad --- /dev/null +++ b/.github/workflows/maven-build.yml @@ -0,0 +1,26 @@ +# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time +# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven + +name: Java CI with Maven + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Set up JDK 11 + uses: actions/setup-java@v2 + with: + java-version: '11' + distribution: 'adopt' + cache: maven + - name: Build with Maven + run: mvn -B package --file pom.xml diff --git a/README.md b/README.md index 6e1a26724c..416e8910c9 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # Distributed version of the Spring PetClinic Sample Application built with Spring Cloud -[![Build Status](https://travis-ci.org/spring-petclinic/spring-petclinic-microservices.svg?branch=master)](https://travis-ci.org/spring-petclinic/spring-petclinic-microservices/) [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) +[![Build Status](https://github.com/spring-petclinic/spring-petclinic-microservices/actions/workflows/maven-build.yml/badge.svg)](https://github.com/spring-petclinic/spring-petclinic-microservices/actions/workflows/maven-build.yml) +[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) This microservices branch was initially derived from [AngularJS version](https://github.com/spring-petclinic/spring-petclinic-angular1) to demonstrate how to split sample Spring application into [microservices](http://www.martinfowler.com/articles/microservices.html). To achieve that goal we use Spring Cloud Gateway, Spring Cloud Circuit Breaker, Spring Cloud Config, Spring Cloud Sleuth, Resilience4j, Micrometer From 501a1ebd7a538568256c01b378b095b5b6fa3e7e Mon Sep 17 00:00:00 2001 From: Antoine Rey Date: Sun, 31 Oct 2021 18:35:19 +0100 Subject: [PATCH 09/22] Delete .travis.yml --- .travis.yml | 2 -- 1 file changed, 2 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 9b16d57715..0000000000 --- a/.travis.yml +++ /dev/null @@ -1,2 +0,0 @@ -language: java -jdk: openjdk8 From c47e99a4c6cd2c0c7ea7ea8e6c5f490aa3a8e250 Mon Sep 17 00:00:00 2001 From: Antoine Rey Date: Sat, 11 Dec 2021 15:19:51 +0100 Subject: [PATCH 10/22] Upgrade to Spring Cloud 2021.0.0 and Spring Boot 2.6.1 (#191) * Upgrade to Spring Cloud 2021.0.0-M2 and Spring Boot 2.6.0-M3 * Upgrade to Spring Cloud 2021.0.0-M3 * Upgrade to Spring Cloud 2021.0.0-RC1 and Spring Boot 2.6.0-RC1 * Upgrade to Spring Boot 2.6.0 * Upgrade to Spring Cloud 2021.0.0 and Spring Boot 2.6.1 * Change copyright date to 2021 --- pom.xml | 9 +++++---- spring-petclinic-admin-server/pom.xml | 4 ++-- .../petclinic/admin/SpringBootAdminApplication.java | 2 +- spring-petclinic-api-gateway/pom.xml | 2 +- .../samples/petclinic/api/ApiGatewayApplication.java | 2 +- .../api/application/CustomersServiceClient.java | 2 +- .../petclinic/api/application/VisitsServiceClient.java | 2 +- .../petclinic/api/boundary/web/ApiGatewayController.java | 2 +- .../samples/petclinic/api/dto/OwnerDetails.java | 2 +- .../samples/petclinic/api/dto/PetDetails.java | 2 +- .../samples/petclinic/api/dto/PetType.java | 2 +- .../samples/petclinic/api/dto/VisitDetails.java | 2 +- .../samples/petclinic/api/dto/Visits.java | 2 +- spring-petclinic-config-server/pom.xml | 2 +- .../petclinic/config/ConfigServerApplication.java | 2 +- .../config/PetclinicConfigServerApplicationTests.java | 2 +- spring-petclinic-customers-service/pom.xml | 2 +- .../petclinic/customers/CustomersServiceApplication.java | 2 +- .../samples/petclinic/customers/model/Owner.java | 2 +- .../petclinic/customers/model/OwnerRepository.java | 2 +- .../samples/petclinic/customers/model/Pet.java | 2 +- .../samples/petclinic/customers/model/PetRepository.java | 2 +- .../samples/petclinic/customers/model/PetType.java | 2 +- .../samples/petclinic/customers/web/OwnerResource.java | 2 +- .../samples/petclinic/customers/web/PetDetails.java | 2 +- .../samples/petclinic/customers/web/PetRequest.java | 2 +- .../samples/petclinic/customers/web/PetResource.java | 2 +- spring-petclinic-discovery-server/pom.xml | 2 +- .../petclinic/discovery/DiscoveryServerApplication.java | 2 +- .../discovery/DiscoveryServerApplicationTests.java | 2 +- spring-petclinic-vets-service/pom.xml | 2 +- .../samples/petclinic/vets/VetsServiceApplication.java | 2 +- .../samples/petclinic/vets/model/Specialty.java | 2 +- .../samples/petclinic/vets/model/Vet.java | 2 +- .../samples/petclinic/vets/model/VetRepository.java | 2 +- .../samples/petclinic/vets/system/CacheConfig.java | 2 +- .../samples/petclinic/vets/system/VetsProperties.java | 2 +- .../samples/petclinic/vets/web/VetResource.java | 2 +- .../samples/petclinic/vets/web/VetResourceTest.java | 2 +- spring-petclinic-visits-service/pom.xml | 2 +- .../petclinic/visits/VisitsServiceApplication.java | 2 +- .../samples/petclinic/visits/model/Visit.java | 2 +- .../samples/petclinic/visits/model/VisitRepository.java | 2 +- .../samples/petclinic/visits/web/VisitResource.java | 2 +- 44 files changed, 49 insertions(+), 48 deletions(-) diff --git a/pom.xml b/pom.xml index c2c8d2f787..a10d6daa83 100644 --- a/pom.xml +++ b/pom.xml @@ -6,12 +6,12 @@ org.springframework.boot spring-boot-starter-parent - 2.5.1 + 2.6.1 org.springframework.samples spring-petclinic-microservices - 2.5.1 + 2.6.1 ${project.artifactId} pom @@ -29,8 +29,8 @@ 1.8 3.17.1 - 2.5.1 - 2020.0.3 + 2.6.0 + 2021.0.0 2.3.10 springcommunity @@ -167,4 +167,5 @@ + diff --git a/spring-petclinic-admin-server/pom.xml b/spring-petclinic-admin-server/pom.xml index 951bff91d8..31ea392892 100644 --- a/spring-petclinic-admin-server/pom.xml +++ b/spring-petclinic-admin-server/pom.xml @@ -12,11 +12,11 @@ org.springframework.samples spring-petclinic-microservices - 2.5.1 + 2.6.1 - 2.4.1 + 2.5.4 9090 ${basedir}/../docker diff --git a/spring-petclinic-admin-server/src/main/java/org/springframework/samples/petclinic/admin/SpringBootAdminApplication.java b/spring-petclinic-admin-server/src/main/java/org/springframework/samples/petclinic/admin/SpringBootAdminApplication.java index 7e0429f94b..49785d15e7 100644 --- a/spring-petclinic-admin-server/src/main/java/org/springframework/samples/petclinic/admin/SpringBootAdminApplication.java +++ b/spring-petclinic-admin-server/src/main/java/org/springframework/samples/petclinic/admin/SpringBootAdminApplication.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-petclinic-api-gateway/pom.xml b/spring-petclinic-api-gateway/pom.xml index 3bc2f6147c..c2d950d7a8 100644 --- a/spring-petclinic-api-gateway/pom.xml +++ b/spring-petclinic-api-gateway/pom.xml @@ -11,7 +11,7 @@ org.springframework.samples spring-petclinic-microservices - 2.5.1 + 2.6.1 diff --git a/spring-petclinic-api-gateway/src/main/java/org/springframework/samples/petclinic/api/ApiGatewayApplication.java b/spring-petclinic-api-gateway/src/main/java/org/springframework/samples/petclinic/api/ApiGatewayApplication.java index fd13cc08d0..df86a6fc25 100644 --- a/spring-petclinic-api-gateway/src/main/java/org/springframework/samples/petclinic/api/ApiGatewayApplication.java +++ b/spring-petclinic-api-gateway/src/main/java/org/springframework/samples/petclinic/api/ApiGatewayApplication.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-petclinic-api-gateway/src/main/java/org/springframework/samples/petclinic/api/application/CustomersServiceClient.java b/spring-petclinic-api-gateway/src/main/java/org/springframework/samples/petclinic/api/application/CustomersServiceClient.java index 0cb31c9b12..e0619b1dcb 100644 --- a/spring-petclinic-api-gateway/src/main/java/org/springframework/samples/petclinic/api/application/CustomersServiceClient.java +++ b/spring-petclinic-api-gateway/src/main/java/org/springframework/samples/petclinic/api/application/CustomersServiceClient.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-petclinic-api-gateway/src/main/java/org/springframework/samples/petclinic/api/application/VisitsServiceClient.java b/spring-petclinic-api-gateway/src/main/java/org/springframework/samples/petclinic/api/application/VisitsServiceClient.java index ffb3d848af..d49dbf9b3d 100644 --- a/spring-petclinic-api-gateway/src/main/java/org/springframework/samples/petclinic/api/application/VisitsServiceClient.java +++ b/spring-petclinic-api-gateway/src/main/java/org/springframework/samples/petclinic/api/application/VisitsServiceClient.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-petclinic-api-gateway/src/main/java/org/springframework/samples/petclinic/api/boundary/web/ApiGatewayController.java b/spring-petclinic-api-gateway/src/main/java/org/springframework/samples/petclinic/api/boundary/web/ApiGatewayController.java index 3d7163e9cb..4cacc61068 100644 --- a/spring-petclinic-api-gateway/src/main/java/org/springframework/samples/petclinic/api/boundary/web/ApiGatewayController.java +++ b/spring-petclinic-api-gateway/src/main/java/org/springframework/samples/petclinic/api/boundary/web/ApiGatewayController.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-petclinic-api-gateway/src/main/java/org/springframework/samples/petclinic/api/dto/OwnerDetails.java b/spring-petclinic-api-gateway/src/main/java/org/springframework/samples/petclinic/api/dto/OwnerDetails.java index 5cea00a88f..35391c026a 100644 --- a/spring-petclinic-api-gateway/src/main/java/org/springframework/samples/petclinic/api/dto/OwnerDetails.java +++ b/spring-petclinic-api-gateway/src/main/java/org/springframework/samples/petclinic/api/dto/OwnerDetails.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-petclinic-api-gateway/src/main/java/org/springframework/samples/petclinic/api/dto/PetDetails.java b/spring-petclinic-api-gateway/src/main/java/org/springframework/samples/petclinic/api/dto/PetDetails.java index e9630d07da..bf064fe6fb 100644 --- a/spring-petclinic-api-gateway/src/main/java/org/springframework/samples/petclinic/api/dto/PetDetails.java +++ b/spring-petclinic-api-gateway/src/main/java/org/springframework/samples/petclinic/api/dto/PetDetails.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-petclinic-api-gateway/src/main/java/org/springframework/samples/petclinic/api/dto/PetType.java b/spring-petclinic-api-gateway/src/main/java/org/springframework/samples/petclinic/api/dto/PetType.java index 63d2b20053..e6b6d9e56b 100644 --- a/spring-petclinic-api-gateway/src/main/java/org/springframework/samples/petclinic/api/dto/PetType.java +++ b/spring-petclinic-api-gateway/src/main/java/org/springframework/samples/petclinic/api/dto/PetType.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-petclinic-api-gateway/src/main/java/org/springframework/samples/petclinic/api/dto/VisitDetails.java b/spring-petclinic-api-gateway/src/main/java/org/springframework/samples/petclinic/api/dto/VisitDetails.java index de3a405439..e9f3535449 100644 --- a/spring-petclinic-api-gateway/src/main/java/org/springframework/samples/petclinic/api/dto/VisitDetails.java +++ b/spring-petclinic-api-gateway/src/main/java/org/springframework/samples/petclinic/api/dto/VisitDetails.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-petclinic-api-gateway/src/main/java/org/springframework/samples/petclinic/api/dto/Visits.java b/spring-petclinic-api-gateway/src/main/java/org/springframework/samples/petclinic/api/dto/Visits.java index 90bd82bee4..fb5851f1fc 100644 --- a/spring-petclinic-api-gateway/src/main/java/org/springframework/samples/petclinic/api/dto/Visits.java +++ b/spring-petclinic-api-gateway/src/main/java/org/springframework/samples/petclinic/api/dto/Visits.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-petclinic-config-server/pom.xml b/spring-petclinic-config-server/pom.xml index ef45071e88..192b42f6a8 100644 --- a/spring-petclinic-config-server/pom.xml +++ b/spring-petclinic-config-server/pom.xml @@ -11,7 +11,7 @@ org.springframework.samples spring-petclinic-microservices - 2.5.1 + 2.6.1 diff --git a/spring-petclinic-config-server/src/main/java/org/springframework/samples/petclinic/config/ConfigServerApplication.java b/spring-petclinic-config-server/src/main/java/org/springframework/samples/petclinic/config/ConfigServerApplication.java index 7d91d10127..e6b810b589 100644 --- a/spring-petclinic-config-server/src/main/java/org/springframework/samples/petclinic/config/ConfigServerApplication.java +++ b/spring-petclinic-config-server/src/main/java/org/springframework/samples/petclinic/config/ConfigServerApplication.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-petclinic-config-server/src/test/java/org/springframework/samples/petclinic/config/PetclinicConfigServerApplicationTests.java b/spring-petclinic-config-server/src/test/java/org/springframework/samples/petclinic/config/PetclinicConfigServerApplicationTests.java index e4cd33f3a1..e3d5191a4f 100644 --- a/spring-petclinic-config-server/src/test/java/org/springframework/samples/petclinic/config/PetclinicConfigServerApplicationTests.java +++ b/spring-petclinic-config-server/src/test/java/org/springframework/samples/petclinic/config/PetclinicConfigServerApplicationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-petclinic-customers-service/pom.xml b/spring-petclinic-customers-service/pom.xml index 2bd021d6b4..0a565e46db 100644 --- a/spring-petclinic-customers-service/pom.xml +++ b/spring-petclinic-customers-service/pom.xml @@ -11,7 +11,7 @@ org.springframework.samples spring-petclinic-microservices - 2.5.1 + 2.6.1 diff --git a/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/CustomersServiceApplication.java b/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/CustomersServiceApplication.java index 3c757c9d47..867cdc198a 100644 --- a/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/CustomersServiceApplication.java +++ b/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/CustomersServiceApplication.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/model/Owner.java b/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/model/Owner.java index 360e7652f3..5429196681 100644 --- a/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/model/Owner.java +++ b/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/model/Owner.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/model/OwnerRepository.java b/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/model/OwnerRepository.java index a9eec088a2..aa720f24f1 100644 --- a/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/model/OwnerRepository.java +++ b/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/model/OwnerRepository.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/model/Pet.java b/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/model/Pet.java index e0d28a9fd9..0dc3ca770e 100644 --- a/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/model/Pet.java +++ b/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/model/Pet.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/model/PetRepository.java b/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/model/PetRepository.java index 93feb49abf..5bd16dbee5 100644 --- a/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/model/PetRepository.java +++ b/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/model/PetRepository.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/model/PetType.java b/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/model/PetType.java index 5ca44874b2..fcac8596c7 100644 --- a/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/model/PetType.java +++ b/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/model/PetType.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/web/OwnerResource.java b/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/web/OwnerResource.java index c9ea4b929f..cc830db7c4 100644 --- a/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/web/OwnerResource.java +++ b/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/web/OwnerResource.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/web/PetDetails.java b/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/web/PetDetails.java index 2cda1e7878..6e61fc0bed 100644 --- a/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/web/PetDetails.java +++ b/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/web/PetDetails.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/web/PetRequest.java b/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/web/PetRequest.java index f7b68f6504..b2e2653169 100644 --- a/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/web/PetRequest.java +++ b/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/web/PetRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/web/PetResource.java b/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/web/PetResource.java index 3b8bdd8870..62245d2e61 100644 --- a/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/web/PetResource.java +++ b/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/web/PetResource.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-petclinic-discovery-server/pom.xml b/spring-petclinic-discovery-server/pom.xml index f08859f303..a56a263198 100644 --- a/spring-petclinic-discovery-server/pom.xml +++ b/spring-petclinic-discovery-server/pom.xml @@ -11,7 +11,7 @@ org.springframework.samples spring-petclinic-microservices - 2.5.1 + 2.6.1 diff --git a/spring-petclinic-discovery-server/src/main/java/org/springframework/samples/petclinic/discovery/DiscoveryServerApplication.java b/spring-petclinic-discovery-server/src/main/java/org/springframework/samples/petclinic/discovery/DiscoveryServerApplication.java index 6c2d281ec7..56c49ed2d5 100644 --- a/spring-petclinic-discovery-server/src/main/java/org/springframework/samples/petclinic/discovery/DiscoveryServerApplication.java +++ b/spring-petclinic-discovery-server/src/main/java/org/springframework/samples/petclinic/discovery/DiscoveryServerApplication.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-petclinic-discovery-server/src/test/java/org/springframework/samples/petclinic/discovery/DiscoveryServerApplicationTests.java b/spring-petclinic-discovery-server/src/test/java/org/springframework/samples/petclinic/discovery/DiscoveryServerApplicationTests.java index a1ede35e1f..8bcc0afd57 100644 --- a/spring-petclinic-discovery-server/src/test/java/org/springframework/samples/petclinic/discovery/DiscoveryServerApplicationTests.java +++ b/spring-petclinic-discovery-server/src/test/java/org/springframework/samples/petclinic/discovery/DiscoveryServerApplicationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-petclinic-vets-service/pom.xml b/spring-petclinic-vets-service/pom.xml index 06ff6cd534..b6392f426d 100644 --- a/spring-petclinic-vets-service/pom.xml +++ b/spring-petclinic-vets-service/pom.xml @@ -11,7 +11,7 @@ org.springframework.samples spring-petclinic-microservices - 2.5.1 + 2.6.1 diff --git a/spring-petclinic-vets-service/src/main/java/org/springframework/samples/petclinic/vets/VetsServiceApplication.java b/spring-petclinic-vets-service/src/main/java/org/springframework/samples/petclinic/vets/VetsServiceApplication.java index 2f5cb36636..e11e1b00d8 100644 --- a/spring-petclinic-vets-service/src/main/java/org/springframework/samples/petclinic/vets/VetsServiceApplication.java +++ b/spring-petclinic-vets-service/src/main/java/org/springframework/samples/petclinic/vets/VetsServiceApplication.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-petclinic-vets-service/src/main/java/org/springframework/samples/petclinic/vets/model/Specialty.java b/spring-petclinic-vets-service/src/main/java/org/springframework/samples/petclinic/vets/model/Specialty.java index 4a22dd167d..e0267d062d 100644 --- a/spring-petclinic-vets-service/src/main/java/org/springframework/samples/petclinic/vets/model/Specialty.java +++ b/spring-petclinic-vets-service/src/main/java/org/springframework/samples/petclinic/vets/model/Specialty.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-petclinic-vets-service/src/main/java/org/springframework/samples/petclinic/vets/model/Vet.java b/spring-petclinic-vets-service/src/main/java/org/springframework/samples/petclinic/vets/model/Vet.java index cddb6a9e3b..31135eccb0 100644 --- a/spring-petclinic-vets-service/src/main/java/org/springframework/samples/petclinic/vets/model/Vet.java +++ b/spring-petclinic-vets-service/src/main/java/org/springframework/samples/petclinic/vets/model/Vet.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-petclinic-vets-service/src/main/java/org/springframework/samples/petclinic/vets/model/VetRepository.java b/spring-petclinic-vets-service/src/main/java/org/springframework/samples/petclinic/vets/model/VetRepository.java index 67e2571333..cb22d143b0 100644 --- a/spring-petclinic-vets-service/src/main/java/org/springframework/samples/petclinic/vets/model/VetRepository.java +++ b/spring-petclinic-vets-service/src/main/java/org/springframework/samples/petclinic/vets/model/VetRepository.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-petclinic-vets-service/src/main/java/org/springframework/samples/petclinic/vets/system/CacheConfig.java b/spring-petclinic-vets-service/src/main/java/org/springframework/samples/petclinic/vets/system/CacheConfig.java index 6941a14466..2f3fb794a1 100644 --- a/spring-petclinic-vets-service/src/main/java/org/springframework/samples/petclinic/vets/system/CacheConfig.java +++ b/spring-petclinic-vets-service/src/main/java/org/springframework/samples/petclinic/vets/system/CacheConfig.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-petclinic-vets-service/src/main/java/org/springframework/samples/petclinic/vets/system/VetsProperties.java b/spring-petclinic-vets-service/src/main/java/org/springframework/samples/petclinic/vets/system/VetsProperties.java index e6529f1020..017bffe717 100644 --- a/spring-petclinic-vets-service/src/main/java/org/springframework/samples/petclinic/vets/system/VetsProperties.java +++ b/spring-petclinic-vets-service/src/main/java/org/springframework/samples/petclinic/vets/system/VetsProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-petclinic-vets-service/src/main/java/org/springframework/samples/petclinic/vets/web/VetResource.java b/spring-petclinic-vets-service/src/main/java/org/springframework/samples/petclinic/vets/web/VetResource.java index d61d5dda17..7e0a57481c 100644 --- a/spring-petclinic-vets-service/src/main/java/org/springframework/samples/petclinic/vets/web/VetResource.java +++ b/spring-petclinic-vets-service/src/main/java/org/springframework/samples/petclinic/vets/web/VetResource.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-petclinic-vets-service/src/test/java/org/springframework/samples/petclinic/vets/web/VetResourceTest.java b/spring-petclinic-vets-service/src/test/java/org/springframework/samples/petclinic/vets/web/VetResourceTest.java index 83e6a6fb61..05e29b9229 100644 --- a/spring-petclinic-vets-service/src/test/java/org/springframework/samples/petclinic/vets/web/VetResourceTest.java +++ b/spring-petclinic-vets-service/src/test/java/org/springframework/samples/petclinic/vets/web/VetResourceTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-petclinic-visits-service/pom.xml b/spring-petclinic-visits-service/pom.xml index 2268234e08..4bfb20abbc 100644 --- a/spring-petclinic-visits-service/pom.xml +++ b/spring-petclinic-visits-service/pom.xml @@ -11,7 +11,7 @@ org.springframework.samples spring-petclinic-microservices - 2.5.1 + 2.6.1 diff --git a/spring-petclinic-visits-service/src/main/java/org/springframework/samples/petclinic/visits/VisitsServiceApplication.java b/spring-petclinic-visits-service/src/main/java/org/springframework/samples/petclinic/visits/VisitsServiceApplication.java index 51a0ecd8c6..78f2963f8d 100644 --- a/spring-petclinic-visits-service/src/main/java/org/springframework/samples/petclinic/visits/VisitsServiceApplication.java +++ b/spring-petclinic-visits-service/src/main/java/org/springframework/samples/petclinic/visits/VisitsServiceApplication.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-petclinic-visits-service/src/main/java/org/springframework/samples/petclinic/visits/model/Visit.java b/spring-petclinic-visits-service/src/main/java/org/springframework/samples/petclinic/visits/model/Visit.java index f799b43a03..c7032140f3 100644 --- a/spring-petclinic-visits-service/src/main/java/org/springframework/samples/petclinic/visits/model/Visit.java +++ b/spring-petclinic-visits-service/src/main/java/org/springframework/samples/petclinic/visits/model/Visit.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-petclinic-visits-service/src/main/java/org/springframework/samples/petclinic/visits/model/VisitRepository.java b/spring-petclinic-visits-service/src/main/java/org/springframework/samples/petclinic/visits/model/VisitRepository.java index 063b3d2709..bd7a6d726b 100644 --- a/spring-petclinic-visits-service/src/main/java/org/springframework/samples/petclinic/visits/model/VisitRepository.java +++ b/spring-petclinic-visits-service/src/main/java/org/springframework/samples/petclinic/visits/model/VisitRepository.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-petclinic-visits-service/src/main/java/org/springframework/samples/petclinic/visits/web/VisitResource.java b/spring-petclinic-visits-service/src/main/java/org/springframework/samples/petclinic/visits/web/VisitResource.java index 4c921d811e..0f1e391b41 100644 --- a/spring-petclinic-visits-service/src/main/java/org/springframework/samples/petclinic/visits/web/VisitResource.java +++ b/spring-petclinic-visits-service/src/main/java/org/springframework/samples/petclinic/visits/web/VisitResource.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. From 0ab2e953e0e23761593a80cd17d7525e3ae32f9d Mon Sep 17 00:00:00 2001 From: Antoine Rey Date: Wed, 15 Dec 2021 18:32:39 +0100 Subject: [PATCH 11/22] Remove Spring Cloud starter bootstrap (#193) * Use Github Actions for CI * Upgrade to Spring Cloud 2021.0.0-M2 and Spring Boot 2.6.0-M3 * Upgrade to Spring Cloud 2021.0.0-M3 * Upgrade to Spring Cloud 2021.0.0-RC1 and Spring Boot 2.6.0-RC1 * Upgrade to Spring Boot 2.6.0 * Upgrade to Spring Cloud 2021.0.0 and Spring Boot 2.6.1 * Change copyright date to 2021 * Migrate from spring-cloud-starter-bootstrap to spring-cloud-starter-config * Remove spring.cloud.loadbalancer.ribbon.enabled deprecated property --- pom.xml | 9 +------- spring-petclinic-admin-server/pom.xml | 4 ---- .../src/main/resources/application.yml | 13 ++++++++++++ .../src/main/resources/bootstrap.yml | 14 ------------- spring-petclinic-api-gateway/pom.xml | 4 ---- .../src/main/resources/application.yml | 16 +++++++++++--- .../src/main/resources/bootstrap.yml | 14 ------------- ...ootstrap-test.yml => application-test.yml} | 0 spring-petclinic-config-server/pom.xml | 4 ---- .../{bootstrap.yml => application.yml} | 1 + spring-petclinic-customers-service/pom.xml | 4 ---- .../src/main/resources/application.properties | 0 .../src/main/resources/application.yml | 13 ++++++++++++ .../src/main/resources/bootstrap.yml | 14 ------------- .../src/test/resources/application-test.yml | 19 ++++++++++++----- .../src/test/resources/bootstrap-test.yml | 2 -- spring-petclinic-discovery-server/pom.xml | 6 +----- .../src/main/resources/application.yml | 21 +++++++++++++++++++ .../src/main/resources/bootstrap.yml | 14 ------------- spring-petclinic-vets-service/pom.xml | 4 ---- .../src/main/resources/application.properties | 2 -- .../src/main/resources/application.yml | 16 ++++++++++++++ .../src/main/resources/bootstrap.yml | 14 ------------- .../src/test/resources/application-test.yml | 19 ++++++++++++----- .../src/test/resources/bootstrap-test.yml | 2 -- spring-petclinic-visits-service/pom.xml | 4 ---- .../src/main/resources/application.properties | 0 .../src/main/resources/application.yml | 13 ++++++++++++ .../src/main/resources/bootstrap.yml | 14 ------------- .../src/test/resources/application-test.yml | 19 ++++++++++++----- .../src/test/resources/bootstrap-test.yml | 2 -- 31 files changed, 134 insertions(+), 147 deletions(-) create mode 100644 spring-petclinic-admin-server/src/main/resources/application.yml delete mode 100644 spring-petclinic-admin-server/src/main/resources/bootstrap.yml delete mode 100644 spring-petclinic-api-gateway/src/main/resources/bootstrap.yml rename spring-petclinic-api-gateway/src/test/resources/{bootstrap-test.yml => application-test.yml} (100%) rename spring-petclinic-config-server/src/main/resources/{bootstrap.yml => application.yml} (91%) delete mode 100644 spring-petclinic-customers-service/src/main/resources/application.properties create mode 100644 spring-petclinic-customers-service/src/main/resources/application.yml delete mode 100644 spring-petclinic-customers-service/src/main/resources/bootstrap.yml delete mode 100644 spring-petclinic-customers-service/src/test/resources/bootstrap-test.yml create mode 100644 spring-petclinic-discovery-server/src/main/resources/application.yml delete mode 100644 spring-petclinic-discovery-server/src/main/resources/bootstrap.yml delete mode 100644 spring-petclinic-vets-service/src/main/resources/application.properties create mode 100644 spring-petclinic-vets-service/src/main/resources/application.yml delete mode 100644 spring-petclinic-vets-service/src/main/resources/bootstrap.yml delete mode 100644 spring-petclinic-vets-service/src/test/resources/bootstrap-test.yml delete mode 100644 spring-petclinic-visits-service/src/main/resources/application.properties create mode 100644 spring-petclinic-visits-service/src/main/resources/application.yml delete mode 100644 spring-petclinic-visits-service/src/main/resources/bootstrap.yml delete mode 100644 spring-petclinic-visits-service/src/test/resources/bootstrap-test.yml diff --git a/pom.xml b/pom.xml index a10d6daa83..60aa27d510 100644 --- a/pom.xml +++ b/pom.xml @@ -69,7 +69,7 @@ - src/main/resources/bootstrap.yml + src/main/resources/application.yml @@ -77,13 +77,6 @@ org.springframework.boot spring-boot-maven-plugin - - true - - - true - - diff --git a/spring-petclinic-admin-server/pom.xml b/spring-petclinic-admin-server/pom.xml index 31ea392892..095a0c0d02 100644 --- a/spring-petclinic-admin-server/pom.xml +++ b/spring-petclinic-admin-server/pom.xml @@ -27,10 +27,6 @@ org.springframework.boot spring-boot-starter - - org.springframework.cloud - spring-cloud-starter-bootstrap - org.springframework.cloud spring-cloud-starter-config diff --git a/spring-petclinic-admin-server/src/main/resources/application.yml b/spring-petclinic-admin-server/src/main/resources/application.yml new file mode 100644 index 0000000000..d745bb18b0 --- /dev/null +++ b/spring-petclinic-admin-server/src/main/resources/application.yml @@ -0,0 +1,13 @@ +spring: + application: + name: admin-server + config: + import: optional:configserver:${CONFIG_SERVER_URL:http://localhost:8888/} + + +--- +spring: + config: + activate: + on-profile: docker + import: configserver:http://config-server:8888 diff --git a/spring-petclinic-admin-server/src/main/resources/bootstrap.yml b/spring-petclinic-admin-server/src/main/resources/bootstrap.yml deleted file mode 100644 index d1ec2a8541..0000000000 --- a/spring-petclinic-admin-server/src/main/resources/bootstrap.yml +++ /dev/null @@ -1,14 +0,0 @@ -spring: - cloud: - config: - uri: http://localhost:8888 - application: - name: admin-server ---- -spring: - config: - activate: - on-profile: docker - cloud: - config: - uri: http://config-server:8888 diff --git a/spring-petclinic-api-gateway/pom.xml b/spring-petclinic-api-gateway/pom.xml index c2d950d7a8..4c82edc9b8 100644 --- a/spring-petclinic-api-gateway/pom.xml +++ b/spring-petclinic-api-gateway/pom.xml @@ -51,10 +51,6 @@ org.springframework.cloud spring-cloud-sleuth-zipkin - - org.springframework.cloud - spring-cloud-starter-bootstrap - org.springframework.cloud spring-cloud-starter-circuitbreaker-reactor-resilience4j diff --git a/spring-petclinic-api-gateway/src/main/resources/application.yml b/spring-petclinic-api-gateway/src/main/resources/application.yml index 74da17a05d..48ead7d0ff 100644 --- a/spring-petclinic-api-gateway/src/main/resources/application.yml +++ b/spring-petclinic-api-gateway/src/main/resources/application.yml @@ -1,8 +1,9 @@ spring: + application: + name: api-gateway + config: + import: optional:configserver:${CONFIG_SERVER_URL:http://localhost:8888/} cloud: - loadbalancer: - ribbon: - enabled: false gateway: routes: - id: vets-service @@ -23,3 +24,12 @@ spring: - Path=/api/customer/** filters: - StripPrefix=2 + + + +--- +spring: + config: + activate: + on-profile: docker + import: configserver:http://config-server:8888 diff --git a/spring-petclinic-api-gateway/src/main/resources/bootstrap.yml b/spring-petclinic-api-gateway/src/main/resources/bootstrap.yml deleted file mode 100644 index 9aef7487e5..0000000000 --- a/spring-petclinic-api-gateway/src/main/resources/bootstrap.yml +++ /dev/null @@ -1,14 +0,0 @@ -spring: - cloud: - config: - uri: http://localhost:8888 - application: - name: api-gateway ---- -spring: - config: - activate: - on-profile: docker - cloud: - config: - uri: http://config-server:8888 diff --git a/spring-petclinic-api-gateway/src/test/resources/bootstrap-test.yml b/spring-petclinic-api-gateway/src/test/resources/application-test.yml similarity index 100% rename from spring-petclinic-api-gateway/src/test/resources/bootstrap-test.yml rename to spring-petclinic-api-gateway/src/test/resources/application-test.yml diff --git a/spring-petclinic-config-server/pom.xml b/spring-petclinic-config-server/pom.xml index 192b42f6a8..68d1f0eb0a 100644 --- a/spring-petclinic-config-server/pom.xml +++ b/spring-petclinic-config-server/pom.xml @@ -32,10 +32,6 @@ org.springframework.cloud spring-cloud-config-server - - org.springframework.cloud - spring-cloud-starter-bootstrap - diff --git a/spring-petclinic-config-server/src/main/resources/bootstrap.yml b/spring-petclinic-config-server/src/main/resources/application.yml similarity index 91% rename from spring-petclinic-config-server/src/main/resources/bootstrap.yml rename to spring-petclinic-config-server/src/main/resources/application.yml index 43e3e9906b..9a58811ba7 100644 --- a/spring-petclinic-config-server/src/main/resources/bootstrap.yml +++ b/spring-petclinic-config-server/src/main/resources/application.yml @@ -5,6 +5,7 @@ spring: server: git: uri: https://github.com/spring-petclinic/spring-petclinic-microservices-config + default-label: main # Use the File System Backend to avoid git pulling. Enable "native" profile in the Config Server. native: searchLocations: file:///${GIT_REPO} diff --git a/spring-petclinic-customers-service/pom.xml b/spring-petclinic-customers-service/pom.xml index 0a565e46db..0f224495b0 100644 --- a/spring-petclinic-customers-service/pom.xml +++ b/spring-petclinic-customers-service/pom.xml @@ -41,10 +41,6 @@ - - org.springframework.cloud - spring-cloud-starter-bootstrap - org.springframework.cloud spring-cloud-starter-config diff --git a/spring-petclinic-customers-service/src/main/resources/application.properties b/spring-petclinic-customers-service/src/main/resources/application.properties deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/spring-petclinic-customers-service/src/main/resources/application.yml b/spring-petclinic-customers-service/src/main/resources/application.yml new file mode 100644 index 0000000000..7c95adf788 --- /dev/null +++ b/spring-petclinic-customers-service/src/main/resources/application.yml @@ -0,0 +1,13 @@ +spring: + application: + name: customers-service + config: + import: optional:configserver:${CONFIG_SERVER_URL:http://localhost:8888/} + + +--- +spring: + config: + activate: + on-profile: docker + import: configserver:http://config-server:8888 diff --git a/spring-petclinic-customers-service/src/main/resources/bootstrap.yml b/spring-petclinic-customers-service/src/main/resources/bootstrap.yml deleted file mode 100644 index 58281a4441..0000000000 --- a/spring-petclinic-customers-service/src/main/resources/bootstrap.yml +++ /dev/null @@ -1,14 +0,0 @@ -spring: - cloud: - config: - uri: http://localhost:8888 - application: - name: customers-service ---- -spring: - config: - activate: - on-profile: docker - cloud: - config: - uri: http://config-server:8888 diff --git a/spring-petclinic-customers-service/src/test/resources/application-test.yml b/spring-petclinic-customers-service/src/test/resources/application-test.yml index 0abdac4430..b9c699b5f0 100644 --- a/spring-petclinic-customers-service/src/test/resources/application-test.yml +++ b/spring-petclinic-customers-service/src/test/resources/application-test.yml @@ -1,9 +1,18 @@ -spring.jpa.hibernate.ddl-auto: none - spring: - datasource: - schema: classpath*:db/hsqldb/schema.sql - data: classpath*:db/hsqldb/data.sql + cloud: + config: + enabled: false + sql: + init: + schema-locations: classpath*:db/hsqldb/schema.sql + data-locations: classpath*:db/hsqldb/data.sql + jpa: + hibernate: + ddl-auto: none + +eureka: + client: + enabled: false logging.level.org.springframework: INFO diff --git a/spring-petclinic-customers-service/src/test/resources/bootstrap-test.yml b/spring-petclinic-customers-service/src/test/resources/bootstrap-test.yml deleted file mode 100644 index cb8e4f5f71..0000000000 --- a/spring-petclinic-customers-service/src/test/resources/bootstrap-test.yml +++ /dev/null @@ -1,2 +0,0 @@ -spring.cloud.config.enabled: false -eureka.client.enabled: false diff --git a/spring-petclinic-discovery-server/pom.xml b/spring-petclinic-discovery-server/pom.xml index a56a263198..0c93219609 100644 --- a/spring-petclinic-discovery-server/pom.xml +++ b/spring-petclinic-discovery-server/pom.xml @@ -30,16 +30,12 @@ org.springframework.cloud - spring-cloud-starter-bootstrap + spring-cloud-starter-netflix-eureka-server org.springframework.cloud spring-cloud-starter-config - - org.springframework.cloud - spring-cloud-starter-netflix-eureka-server - diff --git a/spring-petclinic-discovery-server/src/main/resources/application.yml b/spring-petclinic-discovery-server/src/main/resources/application.yml new file mode 100644 index 0000000000..9fbcbc588a --- /dev/null +++ b/spring-petclinic-discovery-server/src/main/resources/application.yml @@ -0,0 +1,21 @@ +spring: + application: + name: discovery-server + config: + import: optional:configserver:${CONFIG_SERVER_URL:http://localhost:8888/} + +# Avoid some debugging logs at startup +logging: + level: + org: + springframework: + boot: INFO + web: INFO + +--- +spring: + config: + activate: + on-profile: docker + import: configserver:http://config-server:8888 + diff --git a/spring-petclinic-discovery-server/src/main/resources/bootstrap.yml b/spring-petclinic-discovery-server/src/main/resources/bootstrap.yml deleted file mode 100644 index eba87c89e9..0000000000 --- a/spring-petclinic-discovery-server/src/main/resources/bootstrap.yml +++ /dev/null @@ -1,14 +0,0 @@ -spring: - cloud: - config: - uri: http://localhost:8888 - application: - name: discovery-server ---- -spring: - config: - activate: - on-profile: docker - cloud: - config: - uri: http://config-server:8888 diff --git a/spring-petclinic-vets-service/pom.xml b/spring-petclinic-vets-service/pom.xml index b6392f426d..2e017f92f2 100644 --- a/spring-petclinic-vets-service/pom.xml +++ b/spring-petclinic-vets-service/pom.xml @@ -53,10 +53,6 @@ org.springframework.cloud spring-cloud-sleuth-zipkin - - org.springframework.cloud - spring-cloud-starter-bootstrap - org.springframework.cloud spring-cloud-starter-config diff --git a/spring-petclinic-vets-service/src/main/resources/application.properties b/spring-petclinic-vets-service/src/main/resources/application.properties deleted file mode 100644 index 68f17e806f..0000000000 --- a/spring-petclinic-vets-service/src/main/resources/application.properties +++ /dev/null @@ -1,2 +0,0 @@ -spring.profiles.active=production -spring.cache.cache-names=vets diff --git a/spring-petclinic-vets-service/src/main/resources/application.yml b/spring-petclinic-vets-service/src/main/resources/application.yml new file mode 100644 index 0000000000..983a015db8 --- /dev/null +++ b/spring-petclinic-vets-service/src/main/resources/application.yml @@ -0,0 +1,16 @@ +spring: + application: + name: vets-service + config: + import: optional:configserver:${CONFIG_SERVER_URL:http://localhost:8888/} + cache: + cache-names: vets + profiles: + active: production + +--- +spring: + config: + activate: + on-profile: docker + import: configserver:http://config-server:8888 diff --git a/spring-petclinic-vets-service/src/main/resources/bootstrap.yml b/spring-petclinic-vets-service/src/main/resources/bootstrap.yml deleted file mode 100644 index bc2f683e5e..0000000000 --- a/spring-petclinic-vets-service/src/main/resources/bootstrap.yml +++ /dev/null @@ -1,14 +0,0 @@ -spring: - cloud: - config: - uri: http://localhost:8888 - application: - name: vets-service ---- -spring: - config: - activate: - on-profile: docker - cloud: - config: - uri: http://config-server:8888 diff --git a/spring-petclinic-vets-service/src/test/resources/application-test.yml b/spring-petclinic-vets-service/src/test/resources/application-test.yml index 2d18cfdeaf..684fa89889 100644 --- a/spring-petclinic-vets-service/src/test/resources/application-test.yml +++ b/spring-petclinic-vets-service/src/test/resources/application-test.yml @@ -1,9 +1,18 @@ -spring.jpa.hibernate.ddl-auto: none - spring: - datasource: - schema: classpath*:db/hsqldb/schema.sql - data: classpath*:db/hsqldb/data.sql + cloud: + config: + enabled: false + sql: + init: + schema-locations: classpath*:db/hsqldb/schema.sql + data-locations: classpath*:db/hsqldb/data.sql + jpa: + hibernate: + ddl-auto: none + +eureka: + client: + enabled: false vets: cache: diff --git a/spring-petclinic-vets-service/src/test/resources/bootstrap-test.yml b/spring-petclinic-vets-service/src/test/resources/bootstrap-test.yml deleted file mode 100644 index cb8e4f5f71..0000000000 --- a/spring-petclinic-vets-service/src/test/resources/bootstrap-test.yml +++ /dev/null @@ -1,2 +0,0 @@ -spring.cloud.config.enabled: false -eureka.client.enabled: false diff --git a/spring-petclinic-visits-service/pom.xml b/spring-petclinic-visits-service/pom.xml index 4bfb20abbc..5df45a4ba3 100644 --- a/spring-petclinic-visits-service/pom.xml +++ b/spring-petclinic-visits-service/pom.xml @@ -40,10 +40,6 @@ - - org.springframework.cloud - spring-cloud-starter-bootstrap - org.springframework.cloud spring-cloud-starter-config diff --git a/spring-petclinic-visits-service/src/main/resources/application.properties b/spring-petclinic-visits-service/src/main/resources/application.properties deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/spring-petclinic-visits-service/src/main/resources/application.yml b/spring-petclinic-visits-service/src/main/resources/application.yml new file mode 100644 index 0000000000..ada02194cf --- /dev/null +++ b/spring-petclinic-visits-service/src/main/resources/application.yml @@ -0,0 +1,13 @@ +spring: + application: + name: visits-service + config: + import: optional:configserver:${CONFIG_SERVER_URL:http://localhost:8888/} + + +--- +spring: + config: + activate: + on-profile: docker + import: configserver:http://config-server:8888 diff --git a/spring-petclinic-visits-service/src/main/resources/bootstrap.yml b/spring-petclinic-visits-service/src/main/resources/bootstrap.yml deleted file mode 100644 index 92f4fcae36..0000000000 --- a/spring-petclinic-visits-service/src/main/resources/bootstrap.yml +++ /dev/null @@ -1,14 +0,0 @@ -spring: - cloud: - config: - uri: http://localhost:8888 - application: - name: visits-service ---- -spring: - config: - activate: - on-profile: docker - cloud: - config: - uri: http://config-server:8888 diff --git a/spring-petclinic-visits-service/src/test/resources/application-test.yml b/spring-petclinic-visits-service/src/test/resources/application-test.yml index 0abdac4430..b9c699b5f0 100644 --- a/spring-petclinic-visits-service/src/test/resources/application-test.yml +++ b/spring-petclinic-visits-service/src/test/resources/application-test.yml @@ -1,9 +1,18 @@ -spring.jpa.hibernate.ddl-auto: none - spring: - datasource: - schema: classpath*:db/hsqldb/schema.sql - data: classpath*:db/hsqldb/data.sql + cloud: + config: + enabled: false + sql: + init: + schema-locations: classpath*:db/hsqldb/schema.sql + data-locations: classpath*:db/hsqldb/data.sql + jpa: + hibernate: + ddl-auto: none + +eureka: + client: + enabled: false logging.level.org.springframework: INFO diff --git a/spring-petclinic-visits-service/src/test/resources/bootstrap-test.yml b/spring-petclinic-visits-service/src/test/resources/bootstrap-test.yml deleted file mode 100644 index cb8e4f5f71..0000000000 --- a/spring-petclinic-visits-service/src/test/resources/bootstrap-test.yml +++ /dev/null @@ -1,2 +0,0 @@ -spring.cloud.config.enabled: false -eureka.client.enabled: false From 05007a6d435ae5ec8310a4c17d0be6cd2a5470e7 Mon Sep 17 00:00:00 2001 From: Antoine Rey Date: Sat, 18 Dec 2021 15:00:09 +0100 Subject: [PATCH 12/22] Return to owner details (#195) * Use Github Actions for CI * Return to the Owner details view --- .../src/main/resources/static/index.html | 3 +++ .../src/main/resources/static/scripts/app.js | 5 +++-- .../httpErrorHandlingInterceptor.js | 17 +++++++++++++++++ .../scripts/infrastructure/infrastructure.js | 3 +++ .../owner-form/owner-form.controller.js | 19 +++++++------------ .../scripts/pet-form/pet-form.controller.js | 8 +------- .../scripts/visits/visits.controller.js | 7 +------ 7 files changed, 35 insertions(+), 27 deletions(-) create mode 100644 spring-petclinic-api-gateway/src/main/resources/static/scripts/infrastructure/httpErrorHandlingInterceptor.js create mode 100644 spring-petclinic-api-gateway/src/main/resources/static/scripts/infrastructure/infrastructure.js diff --git a/spring-petclinic-api-gateway/src/main/resources/static/index.html b/spring-petclinic-api-gateway/src/main/resources/static/index.html index 221feadb69..c947c3e3ed 100644 --- a/spring-petclinic-api-gateway/src/main/resources/static/index.html +++ b/spring-petclinic-api-gateway/src/main/resources/static/index.html @@ -46,6 +46,9 @@ + + + diff --git a/spring-petclinic-api-gateway/src/main/resources/static/scripts/app.js b/spring-petclinic-api-gateway/src/main/resources/static/scripts/app.js index 870aeb2097..66db62a271 100644 --- a/spring-petclinic-api-gateway/src/main/resources/static/scripts/app.js +++ b/spring-petclinic-api-gateway/src/main/resources/static/scripts/app.js @@ -1,7 +1,7 @@ 'use strict'; /* App Module */ var petClinicApp = angular.module('petClinicApp', [ - 'ui.router', 'layoutNav', 'layoutFooter', 'layoutWelcome', + 'ui.router', 'infrastructure', 'layoutNav', 'layoutFooter', 'layoutWelcome', 'ownerList', 'ownerDetails', 'ownerForm', 'petForm', 'visits', 'vetList']); petClinicApp.config(['$stateProvider', '$urlRouterProvider', '$locationProvider', '$httpProvider', function( @@ -9,6 +9,7 @@ petClinicApp.config(['$stateProvider', '$urlRouterProvider', '$locationProvider' // safari turns to be lazy sending the Cache-Control header $httpProvider.defaults.headers.common["Cache-Control"] = 'no-cache'; + $httpProvider.interceptors.push('HttpErrorHandlingInterceptor'); $locationProvider.hashPrefix('!'); @@ -32,4 +33,4 @@ petClinicApp.config(['$stateProvider', '$urlRouterProvider', '$locationProvider' angular.module(mod).component(mod, { templateUrl: "scripts/fragments/" + c + ".html" }); -}); \ No newline at end of file +}); diff --git a/spring-petclinic-api-gateway/src/main/resources/static/scripts/infrastructure/httpErrorHandlingInterceptor.js b/spring-petclinic-api-gateway/src/main/resources/static/scripts/infrastructure/httpErrorHandlingInterceptor.js new file mode 100644 index 0000000000..f65ab687d0 --- /dev/null +++ b/spring-petclinic-api-gateway/src/main/resources/static/scripts/infrastructure/httpErrorHandlingInterceptor.js @@ -0,0 +1,17 @@ +'use strict'; + +/** + * Global HTTP errors handler. + */ +angular.module('infrastructure') + .factory('HttpErrorHandlingInterceptor', function () { + return { + responseError: function (response) { + var error = response.data; + alert(error.error + "\r\n" + error.errors.map(function (e) { + return e.field + ": " + e.defaultMessage; + }).join("\r\n")); + return response; + } + } + }); diff --git a/spring-petclinic-api-gateway/src/main/resources/static/scripts/infrastructure/infrastructure.js b/spring-petclinic-api-gateway/src/main/resources/static/scripts/infrastructure/infrastructure.js new file mode 100644 index 0000000000..58dd767c42 --- /dev/null +++ b/spring-petclinic-api-gateway/src/main/resources/static/scripts/infrastructure/infrastructure.js @@ -0,0 +1,3 @@ +'use strict'; + +angular.module('infrastructure', []); diff --git a/spring-petclinic-api-gateway/src/main/resources/static/scripts/owner-form/owner-form.controller.js b/spring-petclinic-api-gateway/src/main/resources/static/scripts/owner-form/owner-form.controller.js index f3e0e057c0..d25f7a5697 100644 --- a/spring-petclinic-api-gateway/src/main/resources/static/scripts/owner-form/owner-form.controller.js +++ b/spring-petclinic-api-gateway/src/main/resources/static/scripts/owner-form/owner-form.controller.js @@ -16,20 +16,15 @@ angular.module('ownerForm') self.submitOwnerForm = function () { var id = self.owner.id; - var req; + if (id) { - req = $http.put("api/customer/owners/" + id, self.owner); + $http.put('api/customer/owners/' + id, self.owner).then(function () { + $state.go('ownerDetails', {ownerId: ownerId}); + }); } else { - req = $http.post("api/customer/owners", self.owner); + $http.post('api/customer/owners', self.owner).then(function () { + $state.go('owners'); + }); } - - req.then(function () { - $state.go('owners'); - }, function (response) { - var error = response.data; - alert(error.error + "\r\n" + error.errors.map(function (e) { - return e.field + ": " + e.defaultMessage; - }).join("\r\n")); - }); }; }]); diff --git a/spring-petclinic-api-gateway/src/main/resources/static/scripts/pet-form/pet-form.controller.js b/spring-petclinic-api-gateway/src/main/resources/static/scripts/pet-form/pet-form.controller.js index 9bf24f190e..93bbb6c8b3 100644 --- a/spring-petclinic-api-gateway/src/main/resources/static/scripts/pet-form/pet-form.controller.js +++ b/spring-petclinic-api-gateway/src/main/resources/static/scripts/pet-form/pet-form.controller.js @@ -46,13 +46,7 @@ angular.module('petForm') } req.then(function () { - $state.go("owners", {ownerId: ownerId}); - }, function (response) { - var error = response.data; - error.errors = error.errors || []; - alert(error.error + "\r\n" + error.errors.map(function (e) { - return e.field + ": " + e.defaultMessage; - }).join("\r\n")); + $state.go('ownerDetails', {ownerId: ownerId}); }); }; }]); diff --git a/spring-petclinic-api-gateway/src/main/resources/static/scripts/visits/visits.controller.js b/spring-petclinic-api-gateway/src/main/resources/static/scripts/visits/visits.controller.js index 992765831c..d68798b39d 100644 --- a/spring-petclinic-api-gateway/src/main/resources/static/scripts/visits/visits.controller.js +++ b/spring-petclinic-api-gateway/src/main/resources/static/scripts/visits/visits.controller.js @@ -19,12 +19,7 @@ angular.module('visits') }; $http.post(url, data).then(function () { - $state.go("owners", { ownerId: $stateParams.ownerId }); - }, function (response) { - var error = response.data; - alert(error.error + "\r\n" + error.errors.map(function (e) { - return e.field + ": " + e.defaultMessage; - }).join("\r\n")); + $state.go('ownerDetails', { ownerId: $stateParams.ownerId }); }); }; }]); From 8685f933b81891796c1f25614cb1fd763e2754e1 Mon Sep 17 00:00:00 2001 From: Ramazan Sakin Date: Sun, 27 Feb 2022 12:52:43 +0300 Subject: [PATCH 13/22] Refactoring & clean up (#201) * fix: telephone input field pattern & size conditions set & updated on db script * chore: clean up * feat: min validations added for ids * fix: typo * fix: indentation up --- README.md | 6 +- .../application/CustomersServiceClient.java | 1 - .../owner-form/owner-form.template.html | 3 +- .../petclinic/customers/model/Owner.java | 72 ++++++------------- .../petclinic/customers/model/Pet.java | 43 +---------- .../petclinic/customers/model/PetType.java | 21 +++--- .../customers/web/OwnerResource.java | 7 +- .../petclinic/customers/web/PetResource.java | 8 ++- .../src/main/resources/db/hsqldb/schema.sql | 2 +- .../petclinic/vets/model/Specialty.java | 23 +++--- .../samples/petclinic/vets/model/Vet.java | 39 ++++------ .../samples/petclinic/visits/model/Visit.java | 32 +++------ .../petclinic/visits/web/VisitResource.java | 10 +-- 13 files changed, 82 insertions(+), 185 deletions(-) diff --git a/README.md b/README.md index 416e8910c9..a226b10270 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) This microservices branch was initially derived from [AngularJS version](https://github.com/spring-petclinic/spring-petclinic-angular1) to demonstrate how to split sample Spring application into [microservices](http://www.martinfowler.com/articles/microservices.html). -To achieve that goal we use Spring Cloud Gateway, Spring Cloud Circuit Breaker, Spring Cloud Config, Spring Cloud Sleuth, Resilience4j, Micrometer +To achieve that goal, we use Spring Cloud Gateway, Spring Cloud Circuit Breaker, Spring Cloud Config, Spring Cloud Sleuth, Resilience4j, Micrometer and the Eureka Service Discovery from the [Spring Cloud Netflix](https://github.com/spring-cloud/spring-cloud-netflix) technology stack. ## Starting services locally without Docker @@ -29,7 +29,7 @@ You can tell Config Server to use your local Git repository by using `native` Sp In order to start entire infrastructure using Docker, you have to build images by executing `./mvnw clean install -P buildDocker` from a project root. Once images are ready, you can start them with a single command `docker-compose up`. Containers startup order is coordinated with [`dockerize` script](https://github.com/jwilder/dockerize). -After starting services it takes a while for API Gateway to be in sync with service registry, +After starting services, it takes a while for API Gateway to be in sync with service registry, so don't be scared of initial Spring Cloud Gateway timeouts. You can track services availability using Eureka dashboard available by default at http://localhost:8761. @@ -48,7 +48,7 @@ Each of the java based applications is started with the `chaos-monkey` profile i [See the presentation of the Spring Petclinic Framework version](http://fr.slideshare.net/AntoineRey/spring-framework-petclinic-sample-application) -[A blog bost introducing the Spring Petclinic Microsevices](http://javaetmoi.com/2018/10/architecture-microservices-avec-spring-cloud/) (french language) +[A blog post introducing the Spring Petclinic Microsevices](http://javaetmoi.com/2018/10/architecture-microservices-avec-spring-cloud/) (french language) You can then access petclinic here: http://localhost:8080/ diff --git a/spring-petclinic-api-gateway/src/main/java/org/springframework/samples/petclinic/api/application/CustomersServiceClient.java b/spring-petclinic-api-gateway/src/main/java/org/springframework/samples/petclinic/api/application/CustomersServiceClient.java index e0619b1dcb..691254e009 100644 --- a/spring-petclinic-api-gateway/src/main/java/org/springframework/samples/petclinic/api/application/CustomersServiceClient.java +++ b/spring-petclinic-api-gateway/src/main/java/org/springframework/samples/petclinic/api/application/CustomersServiceClient.java @@ -18,7 +18,6 @@ import lombok.RequiredArgsConstructor; import org.springframework.samples.petclinic.api.dto.OwnerDetails; import org.springframework.stereotype.Component; -import org.springframework.web.client.RestTemplate; import org.springframework.web.reactive.function.client.WebClient; import reactor.core.publisher.Mono; diff --git a/spring-petclinic-api-gateway/src/main/resources/static/scripts/owner-form/owner-form.template.html b/spring-petclinic-api-gateway/src/main/resources/static/scripts/owner-form/owner-form.template.html index 0d49cfb92d..17e97a3f2f 100644 --- a/spring-petclinic-api-gateway/src/main/resources/static/scripts/owner-form/owner-form.template.html +++ b/spring-petclinic-api-gateway/src/main/resources/static/scripts/owner-form/owner-form.template.html @@ -27,7 +27,8 @@

Owner

- + Telephone is required.
diff --git a/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/model/Owner.java b/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/model/Owner.java index 5429196681..88860faa47 100644 --- a/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/model/Owner.java +++ b/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/model/Owner.java @@ -31,8 +31,10 @@ import javax.persistence.OneToMany; import javax.persistence.Table; import javax.validation.constraints.Digits; -import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.NotBlank; +import lombok.Getter; +import lombok.Setter; import org.springframework.beans.support.MutableSortDefinition; import org.springframework.beans.support.PropertyComparator; import org.springframework.core.style.ToStringCreator; @@ -45,6 +47,7 @@ * @author Sam Brannen * @author Michael Isvy * @author Maciej Szarlinski + * @author Ramazan Sakin */ @Entity @Table(name = "owners") @@ -52,76 +55,43 @@ public class Owner { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) + @Getter private Integer id; + @Getter + @Setter @Column(name = "first_name") - @NotEmpty + @NotBlank private String firstName; + @Getter + @Setter @Column(name = "last_name") - @NotEmpty + @NotBlank private String lastName; + @Getter + @Setter @Column(name = "address") - @NotEmpty + @NotBlank private String address; + @Getter + @Setter @Column(name = "city") - @NotEmpty + @NotBlank private String city; + @Getter + @Setter @Column(name = "telephone") - @NotEmpty - @Digits(fraction = 0, integer = 10) + @NotBlank + @Digits(fraction = 0, integer = 12) private String telephone; @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER, mappedBy = "owner") private Set pets; - public Integer getId() { - return id; - } - - public String getFirstName() { - return firstName; - } - - public void setFirstName(final String firstName) { - this.firstName = firstName; - } - - public String getLastName() { - return lastName; - } - - public void setLastName(final String lastName) { - this.lastName = lastName; - } - - public String getAddress() { - return this.address; - } - - public void setAddress(String address) { - this.address = address; - } - - public String getCity() { - return this.city; - } - - public void setCity(String city) { - this.city = city; - } - - public String getTelephone() { - return this.telephone; - } - - public void setTelephone(String telephone) { - this.telephone = telephone; - } - protected Set getPetsInternal() { if (this.pets == null) { this.pets = new HashSet<>(); diff --git a/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/model/Pet.java b/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/model/Pet.java index 0dc3ca770e..b89924f0dd 100644 --- a/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/model/Pet.java +++ b/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/model/Pet.java @@ -29,6 +29,7 @@ import javax.persistence.TemporalType; import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.Data; import org.springframework.core.style.ToStringCreator; /** @@ -38,7 +39,9 @@ * @author Juergen Hoeller * @author Sam Brannen * @author Maciej Szarlinski + * @author Ramazan Sakin */ +@Data @Entity @Table(name = "pets") public class Pet { @@ -62,46 +65,6 @@ public class Pet { @JsonIgnore private Owner owner; - public Integer getId() { - return id; - } - - public void setId(final Integer id) { - this.id = id; - } - - public String getName() { - return this.name; - } - - public void setName(final String name) { - this.name = name; - } - - public Date getBirthDate() { - return birthDate; - } - - public void setBirthDate(final Date birthDate) { - this.birthDate = birthDate; - } - - public PetType getType() { - return type; - } - - public void setType(final PetType type) { - this.type = type; - } - - public Owner getOwner() { - return owner; - } - - public void setOwner(final Owner owner) { - this.owner = owner; - } - @Override public String toString() { return new ToStringCreator(this) diff --git a/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/model/PetType.java b/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/model/PetType.java index fcac8596c7..3a7162fda8 100644 --- a/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/model/PetType.java +++ b/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/model/PetType.java @@ -15,6 +15,9 @@ */ package org.springframework.samples.petclinic.customers.model; +import lombok.Getter; +import lombok.Setter; + import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; @@ -24,27 +27,21 @@ /** * @author Juergen Hoeller + * @author Ramazan Sakin * Can be Cat, Dog, Hamster... */ @Entity @Table(name = "types") public class PetType { + @Id @GeneratedValue(strategy = GenerationType.IDENTITY) + @Getter + @Setter private Integer id; + @Getter + @Setter @Column(name = "name") private String name; - - public Integer getId() { - return id; - } - - public void setId(final Integer id) { - this.id = id; - } - - public String getName() { - return this.name; - } } diff --git a/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/web/OwnerResource.java b/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/web/OwnerResource.java index cc830db7c4..b867f1aa21 100644 --- a/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/web/OwnerResource.java +++ b/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/web/OwnerResource.java @@ -24,6 +24,7 @@ import org.springframework.web.bind.annotation.*; import javax.validation.Valid; +import javax.validation.constraints.Min; import java.util.List; import java.util.Optional; @@ -56,7 +57,7 @@ public Owner createOwner(@Valid @RequestBody Owner owner) { * Read single Owner */ @GetMapping(value = "/{ownerId}") - public Optional findOwner(@PathVariable("ownerId") int ownerId) { + public Optional findOwner(@PathVariable("ownerId") @Min(1) int ownerId) { return ownerRepository.findById(ownerId); } @@ -73,10 +74,10 @@ public List findAll() { */ @PutMapping(value = "/{ownerId}") @ResponseStatus(HttpStatus.NO_CONTENT) - public void updateOwner(@PathVariable("ownerId") int ownerId, @Valid @RequestBody Owner ownerRequest) { + public void updateOwner(@PathVariable("ownerId") @Min(1) int ownerId, @Valid @RequestBody Owner ownerRequest) { final Optional owner = ownerRepository.findById(ownerId); - final Owner ownerModel = owner.orElseThrow(() -> new ResourceNotFoundException("Owner "+ownerId+" not found")); + // This is done by hand for simplicity purpose. In a real life use-case we should consider using MapStruct. ownerModel.setFirstName(ownerRequest.getFirstName()); ownerModel.setLastName(ownerRequest.getLastName()); diff --git a/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/web/PetResource.java b/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/web/PetResource.java index 62245d2e61..7ec597a4b4 100644 --- a/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/web/PetResource.java +++ b/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/web/PetResource.java @@ -22,6 +22,7 @@ import org.springframework.samples.petclinic.customers.model.*; import org.springframework.web.bind.annotation.*; +import javax.validation.constraints.Min; import java.util.List; import java.util.Optional; @@ -30,6 +31,7 @@ * @author Ken Krebs * @author Arjen Poutsma * @author Maciej Szarlinski + * @author Ramazan Sakin */ @RestController @Timed("petclinic.pet") @@ -50,13 +52,13 @@ public List getPetTypes() { @ResponseStatus(HttpStatus.CREATED) public Pet processCreationForm( @RequestBody PetRequest petRequest, - @PathVariable("ownerId") int ownerId) { + @PathVariable("ownerId") @Min(1) int ownerId) { - final Pet pet = new Pet(); final Optional optionalOwner = ownerRepository.findById(ownerId); Owner owner = optionalOwner.orElseThrow(() -> new ResourceNotFoundException("Owner "+ownerId+" not found")); - owner.addPet(pet); + final Pet pet = new Pet(); + owner.addPet(pet); return save(pet, petRequest); } diff --git a/spring-petclinic-customers-service/src/main/resources/db/hsqldb/schema.sql b/spring-petclinic-customers-service/src/main/resources/db/hsqldb/schema.sql index 9aa6666bf9..33d42ee5ac 100644 --- a/spring-petclinic-customers-service/src/main/resources/db/hsqldb/schema.sql +++ b/spring-petclinic-customers-service/src/main/resources/db/hsqldb/schema.sql @@ -14,7 +14,7 @@ CREATE TABLE owners ( last_name VARCHAR(30), address VARCHAR(255), city VARCHAR(80), - telephone VARCHAR(20) + telephone VARCHAR(12) ); CREATE INDEX owners_last_name ON owners (last_name); diff --git a/spring-petclinic-vets-service/src/main/java/org/springframework/samples/petclinic/vets/model/Specialty.java b/spring-petclinic-vets-service/src/main/java/org/springframework/samples/petclinic/vets/model/Specialty.java index e0267d062d..c5c0869c6e 100644 --- a/spring-petclinic-vets-service/src/main/java/org/springframework/samples/petclinic/vets/model/Specialty.java +++ b/spring-petclinic-vets-service/src/main/java/org/springframework/samples/petclinic/vets/model/Specialty.java @@ -15,6 +15,9 @@ */ package org.springframework.samples.petclinic.vets.model; +import lombok.Getter; +import lombok.Setter; + import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; @@ -26,30 +29,20 @@ * Models a {@link Vet Vet's} specialty (for example, dentistry). * * @author Juergen Hoeller + * @author Ramazan Sakin */ + @Entity @Table(name = "specialties") public class Specialty { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) + @Getter private Integer id; + @Getter + @Setter @Column(name = "name") private String name; - public Integer getId() { - return id; - } - - public void setId(final Integer id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(final String name) { - this.name = name; - } } diff --git a/spring-petclinic-vets-service/src/main/java/org/springframework/samples/petclinic/vets/model/Vet.java b/spring-petclinic-vets-service/src/main/java/org/springframework/samples/petclinic/vets/model/Vet.java index 31135eccb0..4976a39bce 100644 --- a/spring-petclinic-vets-service/src/main/java/org/springframework/samples/petclinic/vets/model/Vet.java +++ b/spring-petclinic-vets-service/src/main/java/org/springframework/samples/petclinic/vets/model/Vet.java @@ -31,9 +31,11 @@ import javax.persistence.JoinTable; import javax.persistence.ManyToMany; import javax.persistence.Table; -import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.NotBlank; import javax.xml.bind.annotation.XmlElement; +import lombok.Getter; +import lombok.Setter; import org.springframework.beans.support.MutableSortDefinition; import org.springframework.beans.support.PropertyComparator; @@ -45,6 +47,7 @@ * @author Sam Brannen * @author Arjen Poutsma * @author Maciej Szarlinski + * @author Ramazan Sakin */ @Entity @Table(name = "vets") @@ -52,14 +55,20 @@ public class Vet { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) + @Getter + @Setter private Integer id; @Column(name = "first_name") - @NotEmpty + @NotBlank + @Getter + @Setter private String firstName; @Column(name = "last_name") - @NotEmpty + @NotBlank + @Getter + @Setter private String lastName; @ManyToMany(fetch = FetchType.EAGER) @@ -67,30 +76,6 @@ public class Vet { inverseJoinColumns = @JoinColumn(name = "specialty_id")) private Set specialties; - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public String getFirstName() { - return this.firstName; - } - - public void setFirstName(String firstName) { - this.firstName = firstName; - } - - public String getLastName() { - return this.lastName; - } - - public void setLastName(String lastName) { - this.lastName = lastName; - } - protected Set getSpecialtiesInternal() { if (this.specialties == null) { this.specialties = new HashSet<>(); diff --git a/spring-petclinic-visits-service/src/main/java/org/springframework/samples/petclinic/visits/model/Visit.java b/spring-petclinic-visits-service/src/main/java/org/springframework/samples/petclinic/visits/model/Visit.java index c7032140f3..deede8eed1 100644 --- a/spring-petclinic-visits-service/src/main/java/org/springframework/samples/petclinic/visits/model/Visit.java +++ b/spring-petclinic-visits-service/src/main/java/org/springframework/samples/petclinic/visits/model/Visit.java @@ -16,7 +16,11 @@ package org.springframework.samples.petclinic.visits.model; import com.fasterxml.jackson.annotation.JsonFormat; -import java.util.Date; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; @@ -26,19 +30,19 @@ import javax.persistence.Temporal; import javax.persistence.TemporalType; import javax.validation.constraints.Size; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.NoArgsConstructor; +import java.util.Date; /** * Simple JavaBean domain object representing a visit. * * @author Ken Krebs * @author Maciej Szarlinski + * @author Ramazan Sakin */ @Entity @Table(name = "visits") @Builder(builderMethodName = "visit") +@Data @NoArgsConstructor @AllArgsConstructor public class Visit { @@ -60,24 +64,4 @@ public class Visit { @Column(name = "pet_id") private int petId; - public Integer getId() { - return id; - } - - public Date getDate() { - return date; - } - - public String getDescription() { - return description; - } - - public int getPetId() { - return petId; - } - - public void setPetId(final int petId) { - this.petId = petId; - } - } diff --git a/spring-petclinic-visits-service/src/main/java/org/springframework/samples/petclinic/visits/web/VisitResource.java b/spring-petclinic-visits-service/src/main/java/org/springframework/samples/petclinic/visits/web/VisitResource.java index 0f1e391b41..ab940b5bc3 100644 --- a/spring-petclinic-visits-service/src/main/java/org/springframework/samples/petclinic/visits/web/VisitResource.java +++ b/spring-petclinic-visits-service/src/main/java/org/springframework/samples/petclinic/visits/web/VisitResource.java @@ -17,6 +17,7 @@ import java.util.List; import javax.validation.Valid; +import javax.validation.constraints.Min; import io.micrometer.core.annotation.Timed; import lombok.RequiredArgsConstructor; @@ -39,6 +40,7 @@ * @author Arjen Poutsma * @author Michael Isvy * @author Maciej Szarlinski + * @author Ramazan Sakin */ @RestController @RequiredArgsConstructor @@ -50,9 +52,9 @@ class VisitResource { @PostMapping("owners/*/pets/{petId}/visits") @ResponseStatus(HttpStatus.CREATED) - public Visit create( + public Visit create( @Valid @RequestBody Visit visit, - @PathVariable("petId") int petId) { + @PathVariable("petId") @Min(1) int petId) { visit.setPetId(petId); log.info("Saving visit {}", visit); @@ -60,12 +62,12 @@ public Visit create( } @GetMapping("owners/*/pets/{petId}/visits") - public List visits(@PathVariable("petId") int petId) { + public List visits(@PathVariable("petId") @Min(1) int petId) { return visitRepository.findByPetId(petId); } @GetMapping("pets/visits") - public Visits visitsMultiGet(@RequestParam("petId") List petIds) { + public Visits visitsMultiGet(@RequestParam("petId") List petIds) { final List byPetIdIn = visitRepository.findByPetIdIn(petIds); return new Visits(byPetIdIn); } From f8d05badb197c220558c99dd9b980f3137b64786 Mon Sep 17 00:00:00 2001 From: Antoine Rey Date: Fri, 25 Mar 2022 08:18:28 +0100 Subject: [PATCH 14/22] Spring Cloud 2021.0.1 (#202) * Use Github Actions for CI * Bump to Spring Cloud 2021.0.1 and Spring Boot 2.6.3 --- pom.xml | 6 +++--- spring-petclinic-admin-server/pom.xml | 2 +- spring-petclinic-api-gateway/pom.xml | 2 +- spring-petclinic-config-server/pom.xml | 2 +- spring-petclinic-customers-service/pom.xml | 2 +- spring-petclinic-discovery-server/pom.xml | 2 +- spring-petclinic-vets-service/pom.xml | 2 +- spring-petclinic-visits-service/pom.xml | 2 +- 8 files changed, 10 insertions(+), 10 deletions(-) diff --git a/pom.xml b/pom.xml index 60aa27d510..a405630674 100644 --- a/pom.xml +++ b/pom.xml @@ -6,12 +6,12 @@ org.springframework.boot spring-boot-starter-parent - 2.6.1 + 2.6.3 org.springframework.samples spring-petclinic-microservices - 2.6.1 + 2.6.3 ${project.artifactId} pom @@ -30,7 +30,7 @@ 3.17.1 2.6.0 - 2021.0.0 + 2021.0.1 2.3.10 springcommunity diff --git a/spring-petclinic-admin-server/pom.xml b/spring-petclinic-admin-server/pom.xml index 095a0c0d02..39c3b00279 100644 --- a/spring-petclinic-admin-server/pom.xml +++ b/spring-petclinic-admin-server/pom.xml @@ -12,7 +12,7 @@ org.springframework.samples spring-petclinic-microservices - 2.6.1 + 2.6.3 diff --git a/spring-petclinic-api-gateway/pom.xml b/spring-petclinic-api-gateway/pom.xml index 4c82edc9b8..fa27bba623 100644 --- a/spring-petclinic-api-gateway/pom.xml +++ b/spring-petclinic-api-gateway/pom.xml @@ -11,7 +11,7 @@ org.springframework.samples spring-petclinic-microservices - 2.6.1 + 2.6.3 diff --git a/spring-petclinic-config-server/pom.xml b/spring-petclinic-config-server/pom.xml index 68d1f0eb0a..347ed9384b 100644 --- a/spring-petclinic-config-server/pom.xml +++ b/spring-petclinic-config-server/pom.xml @@ -11,7 +11,7 @@ org.springframework.samples spring-petclinic-microservices - 2.6.1 + 2.6.3 diff --git a/spring-petclinic-customers-service/pom.xml b/spring-petclinic-customers-service/pom.xml index 0f224495b0..6f1711ae6f 100644 --- a/spring-petclinic-customers-service/pom.xml +++ b/spring-petclinic-customers-service/pom.xml @@ -11,7 +11,7 @@ org.springframework.samples spring-petclinic-microservices - 2.6.1 + 2.6.3 diff --git a/spring-petclinic-discovery-server/pom.xml b/spring-petclinic-discovery-server/pom.xml index 0c93219609..3933a41b62 100644 --- a/spring-petclinic-discovery-server/pom.xml +++ b/spring-petclinic-discovery-server/pom.xml @@ -11,7 +11,7 @@ org.springframework.samples spring-petclinic-microservices - 2.6.1 + 2.6.3 diff --git a/spring-petclinic-vets-service/pom.xml b/spring-petclinic-vets-service/pom.xml index 2e017f92f2..4c3c77046c 100644 --- a/spring-petclinic-vets-service/pom.xml +++ b/spring-petclinic-vets-service/pom.xml @@ -11,7 +11,7 @@ org.springframework.samples spring-petclinic-microservices - 2.6.1 + 2.6.3 diff --git a/spring-petclinic-visits-service/pom.xml b/spring-petclinic-visits-service/pom.xml index 5df45a4ba3..89aed0d6b6 100644 --- a/spring-petclinic-visits-service/pom.xml +++ b/spring-petclinic-visits-service/pom.xml @@ -11,7 +11,7 @@ org.springframework.samples spring-petclinic-microservices - 2.6.1 + 2.6.3 From a05f4fba7ce2877ee277b4b710d0f1ff5f1fb2ca Mon Sep 17 00:00:00 2001 From: Antoine Rey Date: Sun, 15 May 2022 18:58:56 +0200 Subject: [PATCH 15/22] Bump to Spring Cloud 2021.0.2 and Spring Boot 2.6.7 (#204) * Use Github Actions for CI * Bump to Spring Cloud 2021.0.2 and Spring Boot 2.6.7 --- pom.xml | 6 +++--- spring-petclinic-admin-server/pom.xml | 2 +- spring-petclinic-api-gateway/pom.xml | 2 +- spring-petclinic-config-server/pom.xml | 2 +- spring-petclinic-customers-service/pom.xml | 2 +- spring-petclinic-discovery-server/pom.xml | 2 +- spring-petclinic-vets-service/pom.xml | 2 +- spring-petclinic-visits-service/pom.xml | 2 +- 8 files changed, 10 insertions(+), 10 deletions(-) diff --git a/pom.xml b/pom.xml index a405630674..95cb2481d9 100644 --- a/pom.xml +++ b/pom.xml @@ -6,12 +6,12 @@ org.springframework.boot spring-boot-starter-parent - 2.6.3 + 2.6.7 org.springframework.samples spring-petclinic-microservices - 2.6.3 + 2.6.7 ${project.artifactId} pom @@ -30,7 +30,7 @@ 3.17.1 2.6.0 - 2021.0.1 + 2021.0.2 2.3.10 springcommunity diff --git a/spring-petclinic-admin-server/pom.xml b/spring-petclinic-admin-server/pom.xml index 39c3b00279..e56d0d4aea 100644 --- a/spring-petclinic-admin-server/pom.xml +++ b/spring-petclinic-admin-server/pom.xml @@ -12,7 +12,7 @@ org.springframework.samples spring-petclinic-microservices - 2.6.3 + 2.6.7 diff --git a/spring-petclinic-api-gateway/pom.xml b/spring-petclinic-api-gateway/pom.xml index fa27bba623..84c7d9f875 100644 --- a/spring-petclinic-api-gateway/pom.xml +++ b/spring-petclinic-api-gateway/pom.xml @@ -11,7 +11,7 @@ org.springframework.samples spring-petclinic-microservices - 2.6.3 + 2.6.7 diff --git a/spring-petclinic-config-server/pom.xml b/spring-petclinic-config-server/pom.xml index 347ed9384b..f2c3c963c3 100644 --- a/spring-petclinic-config-server/pom.xml +++ b/spring-petclinic-config-server/pom.xml @@ -11,7 +11,7 @@ org.springframework.samples spring-petclinic-microservices - 2.6.3 + 2.6.7 diff --git a/spring-petclinic-customers-service/pom.xml b/spring-petclinic-customers-service/pom.xml index 6f1711ae6f..5435bb014b 100644 --- a/spring-petclinic-customers-service/pom.xml +++ b/spring-petclinic-customers-service/pom.xml @@ -11,7 +11,7 @@ org.springframework.samples spring-petclinic-microservices - 2.6.3 + 2.6.7 diff --git a/spring-petclinic-discovery-server/pom.xml b/spring-petclinic-discovery-server/pom.xml index 3933a41b62..c81faf4f8b 100644 --- a/spring-petclinic-discovery-server/pom.xml +++ b/spring-petclinic-discovery-server/pom.xml @@ -11,7 +11,7 @@ org.springframework.samples spring-petclinic-microservices - 2.6.3 + 2.6.7 diff --git a/spring-petclinic-vets-service/pom.xml b/spring-petclinic-vets-service/pom.xml index 4c3c77046c..26fa5779c7 100644 --- a/spring-petclinic-vets-service/pom.xml +++ b/spring-petclinic-vets-service/pom.xml @@ -11,7 +11,7 @@ org.springframework.samples spring-petclinic-microservices - 2.6.3 + 2.6.7 diff --git a/spring-petclinic-visits-service/pom.xml b/spring-petclinic-visits-service/pom.xml index 89aed0d6b6..949d1bb621 100644 --- a/spring-petclinic-visits-service/pom.xml +++ b/spring-petclinic-visits-service/pom.xml @@ -11,7 +11,7 @@ org.springframework.samples spring-petclinic-microservices - 2.6.3 + 2.6.7 From c43023ae044908779ce98b6c90375bdbea938dc7 Mon Sep 17 00:00:00 2001 From: felipmiguel Date: Tue, 29 Nov 2022 11:14:06 +0100 Subject: [PATCH 16/22] update spring 2.6.7 -> 2.6.11 --- pom.xml | 4 ++-- spring-petclinic-admin-server/pom.xml | 2 +- spring-petclinic-api-gateway/pom.xml | 2 +- spring-petclinic-config-server/pom.xml | 2 +- spring-petclinic-customers-service/pom.xml | 2 +- spring-petclinic-discovery-server/pom.xml | 2 +- spring-petclinic-vets-service/pom.xml | 2 +- spring-petclinic-visits-service/pom.xml | 2 +- 8 files changed, 9 insertions(+), 9 deletions(-) diff --git a/pom.xml b/pom.xml index 1bebf79eaf..f6d44aaf7f 100644 --- a/pom.xml +++ b/pom.xml @@ -6,12 +6,12 @@ org.springframework.boot spring-boot-starter-parent - 2.6.7 + 2.6.11 org.springframework.samples spring-petclinic-microservices - 2.6.7 + 2.6.11 ${project.artifactId} pom diff --git a/spring-petclinic-admin-server/pom.xml b/spring-petclinic-admin-server/pom.xml index 51b6ae3397..16c696fc8e 100644 --- a/spring-petclinic-admin-server/pom.xml +++ b/spring-petclinic-admin-server/pom.xml @@ -12,7 +12,7 @@ org.springframework.samples spring-petclinic-microservices - 2.6.7 + 2.6.11 diff --git a/spring-petclinic-api-gateway/pom.xml b/spring-petclinic-api-gateway/pom.xml index 8748503b4e..5c7c014944 100644 --- a/spring-petclinic-api-gateway/pom.xml +++ b/spring-petclinic-api-gateway/pom.xml @@ -11,7 +11,7 @@ org.springframework.samples spring-petclinic-microservices - 2.6.7 + 2.6.11 diff --git a/spring-petclinic-config-server/pom.xml b/spring-petclinic-config-server/pom.xml index ba59e38c30..17748522c2 100644 --- a/spring-petclinic-config-server/pom.xml +++ b/spring-petclinic-config-server/pom.xml @@ -11,7 +11,7 @@ org.springframework.samples spring-petclinic-microservices - 2.6.7 + 2.6.11 diff --git a/spring-petclinic-customers-service/pom.xml b/spring-petclinic-customers-service/pom.xml index 18e394911f..82baa5bd5b 100644 --- a/spring-petclinic-customers-service/pom.xml +++ b/spring-petclinic-customers-service/pom.xml @@ -11,7 +11,7 @@ org.springframework.samples spring-petclinic-microservices - 2.6.7 + 2.6.11 diff --git a/spring-petclinic-discovery-server/pom.xml b/spring-petclinic-discovery-server/pom.xml index edfd28aea6..60a7865c6f 100644 --- a/spring-petclinic-discovery-server/pom.xml +++ b/spring-petclinic-discovery-server/pom.xml @@ -11,7 +11,7 @@ org.springframework.samples spring-petclinic-microservices - 2.6.7 + 2.6.11 diff --git a/spring-petclinic-vets-service/pom.xml b/spring-petclinic-vets-service/pom.xml index 7dac1f2fd2..9b155f2ddf 100644 --- a/spring-petclinic-vets-service/pom.xml +++ b/spring-petclinic-vets-service/pom.xml @@ -11,7 +11,7 @@ org.springframework.samples spring-petclinic-microservices - 2.6.7 + 2.6.11 diff --git a/spring-petclinic-visits-service/pom.xml b/spring-petclinic-visits-service/pom.xml index 13048f5c54..dd53f32777 100644 --- a/spring-petclinic-visits-service/pom.xml +++ b/spring-petclinic-visits-service/pom.xml @@ -12,7 +12,7 @@ org.springframework.samples spring-petclinic-microservices - 2.6.7 + 2.6.11 From 86e5bfb61ae80ad30c1ea597b5f0d8be23885614 Mon Sep 17 00:00:00 2001 From: felipmiguel Date: Wed, 30 Nov 2022 21:33:43 +0100 Subject: [PATCH 17/22] database initialization update 2.7.6 --- .../src/main/resources/{db/hsqldb/data.sql => data-hsqldb.sql} | 0 .../src/main/resources/{db/mysql/data.sql => data-mysql.sql} | 0 .../main/resources/{db/hsqldb/schema.sql => schema-hsqldb.sql} | 0 .../src/main/resources/{db/mysql/schema.sql => schema-mysql.sql} | 0 .../src/main/resources/{db/hsqldb/data.sql => data-hsqldb.sql} | 0 .../src/main/resources/{db/mysql/data.sql => data-mysql.sql} | 0 .../main/resources/{db/hsqldb/schema.sql => schema-hsqldb.sql} | 0 .../src/main/resources/{db/mysql/schema.sql => schema-mysql.sql} | 0 .../src/main/resources/{db/hsqldb/data.sql => data-hsqldb.sql} | 0 .../src/main/resources/{db/mysql/data.sql => data-mysql.sql} | 0 .../main/resources/{db/hsqldb/schema.sql => schema-hsqldb.sql} | 0 .../src/main/resources/{db/mysql/schema.sql => schema-mysql.sql} | 0 12 files changed, 0 insertions(+), 0 deletions(-) rename spring-petclinic-customers-service/src/main/resources/{db/hsqldb/data.sql => data-hsqldb.sql} (100%) rename spring-petclinic-customers-service/src/main/resources/{db/mysql/data.sql => data-mysql.sql} (100%) rename spring-petclinic-customers-service/src/main/resources/{db/hsqldb/schema.sql => schema-hsqldb.sql} (100%) rename spring-petclinic-customers-service/src/main/resources/{db/mysql/schema.sql => schema-mysql.sql} (100%) rename spring-petclinic-vets-service/src/main/resources/{db/hsqldb/data.sql => data-hsqldb.sql} (100%) rename spring-petclinic-vets-service/src/main/resources/{db/mysql/data.sql => data-mysql.sql} (100%) rename spring-petclinic-vets-service/src/main/resources/{db/hsqldb/schema.sql => schema-hsqldb.sql} (100%) rename spring-petclinic-vets-service/src/main/resources/{db/mysql/schema.sql => schema-mysql.sql} (100%) rename spring-petclinic-visits-service/src/main/resources/{db/hsqldb/data.sql => data-hsqldb.sql} (100%) rename spring-petclinic-visits-service/src/main/resources/{db/mysql/data.sql => data-mysql.sql} (100%) rename spring-petclinic-visits-service/src/main/resources/{db/hsqldb/schema.sql => schema-hsqldb.sql} (100%) rename spring-petclinic-visits-service/src/main/resources/{db/mysql/schema.sql => schema-mysql.sql} (100%) diff --git a/spring-petclinic-customers-service/src/main/resources/db/hsqldb/data.sql b/spring-petclinic-customers-service/src/main/resources/data-hsqldb.sql similarity index 100% rename from spring-petclinic-customers-service/src/main/resources/db/hsqldb/data.sql rename to spring-petclinic-customers-service/src/main/resources/data-hsqldb.sql diff --git a/spring-petclinic-customers-service/src/main/resources/db/mysql/data.sql b/spring-petclinic-customers-service/src/main/resources/data-mysql.sql similarity index 100% rename from spring-petclinic-customers-service/src/main/resources/db/mysql/data.sql rename to spring-petclinic-customers-service/src/main/resources/data-mysql.sql diff --git a/spring-petclinic-customers-service/src/main/resources/db/hsqldb/schema.sql b/spring-petclinic-customers-service/src/main/resources/schema-hsqldb.sql similarity index 100% rename from spring-petclinic-customers-service/src/main/resources/db/hsqldb/schema.sql rename to spring-petclinic-customers-service/src/main/resources/schema-hsqldb.sql diff --git a/spring-petclinic-customers-service/src/main/resources/db/mysql/schema.sql b/spring-petclinic-customers-service/src/main/resources/schema-mysql.sql similarity index 100% rename from spring-petclinic-customers-service/src/main/resources/db/mysql/schema.sql rename to spring-petclinic-customers-service/src/main/resources/schema-mysql.sql diff --git a/spring-petclinic-vets-service/src/main/resources/db/hsqldb/data.sql b/spring-petclinic-vets-service/src/main/resources/data-hsqldb.sql similarity index 100% rename from spring-petclinic-vets-service/src/main/resources/db/hsqldb/data.sql rename to spring-petclinic-vets-service/src/main/resources/data-hsqldb.sql diff --git a/spring-petclinic-vets-service/src/main/resources/db/mysql/data.sql b/spring-petclinic-vets-service/src/main/resources/data-mysql.sql similarity index 100% rename from spring-petclinic-vets-service/src/main/resources/db/mysql/data.sql rename to spring-petclinic-vets-service/src/main/resources/data-mysql.sql diff --git a/spring-petclinic-vets-service/src/main/resources/db/hsqldb/schema.sql b/spring-petclinic-vets-service/src/main/resources/schema-hsqldb.sql similarity index 100% rename from spring-petclinic-vets-service/src/main/resources/db/hsqldb/schema.sql rename to spring-petclinic-vets-service/src/main/resources/schema-hsqldb.sql diff --git a/spring-petclinic-vets-service/src/main/resources/db/mysql/schema.sql b/spring-petclinic-vets-service/src/main/resources/schema-mysql.sql similarity index 100% rename from spring-petclinic-vets-service/src/main/resources/db/mysql/schema.sql rename to spring-petclinic-vets-service/src/main/resources/schema-mysql.sql diff --git a/spring-petclinic-visits-service/src/main/resources/db/hsqldb/data.sql b/spring-petclinic-visits-service/src/main/resources/data-hsqldb.sql similarity index 100% rename from spring-petclinic-visits-service/src/main/resources/db/hsqldb/data.sql rename to spring-petclinic-visits-service/src/main/resources/data-hsqldb.sql diff --git a/spring-petclinic-visits-service/src/main/resources/db/mysql/data.sql b/spring-petclinic-visits-service/src/main/resources/data-mysql.sql similarity index 100% rename from spring-petclinic-visits-service/src/main/resources/db/mysql/data.sql rename to spring-petclinic-visits-service/src/main/resources/data-mysql.sql diff --git a/spring-petclinic-visits-service/src/main/resources/db/hsqldb/schema.sql b/spring-petclinic-visits-service/src/main/resources/schema-hsqldb.sql similarity index 100% rename from spring-petclinic-visits-service/src/main/resources/db/hsqldb/schema.sql rename to spring-petclinic-visits-service/src/main/resources/schema-hsqldb.sql diff --git a/spring-petclinic-visits-service/src/main/resources/db/mysql/schema.sql b/spring-petclinic-visits-service/src/main/resources/schema-mysql.sql similarity index 100% rename from spring-petclinic-visits-service/src/main/resources/db/mysql/schema.sql rename to spring-petclinic-visits-service/src/main/resources/schema-mysql.sql From 336dd7c2f6bc41878c90d72648f7846b4836d0aa Mon Sep 17 00:00:00 2001 From: felipmiguel Date: Wed, 30 Nov 2022 21:37:41 +0100 Subject: [PATCH 18/22] remove bootstrap.yml --- .../src/main/resources/bootstrap.yml | 14 -------------- .../src/main/resources/bootstrap.yml | 14 -------------- .../src/main/resources/bootstrap.yml | 14 -------------- .../src/main/resources/bootstrap.yml | 14 -------------- .../src/main/resources/bootstrap.yml | 14 -------------- .../src/main/resources/bootstrap.yml | 14 -------------- 6 files changed, 84 deletions(-) delete mode 100644 spring-petclinic-admin-server/src/main/resources/bootstrap.yml delete mode 100644 spring-petclinic-api-gateway/src/main/resources/bootstrap.yml delete mode 100644 spring-petclinic-customers-service/src/main/resources/bootstrap.yml delete mode 100644 spring-petclinic-discovery-server/src/main/resources/bootstrap.yml delete mode 100644 spring-petclinic-vets-service/src/main/resources/bootstrap.yml delete mode 100644 spring-petclinic-visits-service/src/main/resources/bootstrap.yml diff --git a/spring-petclinic-admin-server/src/main/resources/bootstrap.yml b/spring-petclinic-admin-server/src/main/resources/bootstrap.yml deleted file mode 100644 index d1ec2a8541..0000000000 --- a/spring-petclinic-admin-server/src/main/resources/bootstrap.yml +++ /dev/null @@ -1,14 +0,0 @@ -spring: - cloud: - config: - uri: http://localhost:8888 - application: - name: admin-server ---- -spring: - config: - activate: - on-profile: docker - cloud: - config: - uri: http://config-server:8888 diff --git a/spring-petclinic-api-gateway/src/main/resources/bootstrap.yml b/spring-petclinic-api-gateway/src/main/resources/bootstrap.yml deleted file mode 100644 index 9aef7487e5..0000000000 --- a/spring-petclinic-api-gateway/src/main/resources/bootstrap.yml +++ /dev/null @@ -1,14 +0,0 @@ -spring: - cloud: - config: - uri: http://localhost:8888 - application: - name: api-gateway ---- -spring: - config: - activate: - on-profile: docker - cloud: - config: - uri: http://config-server:8888 diff --git a/spring-petclinic-customers-service/src/main/resources/bootstrap.yml b/spring-petclinic-customers-service/src/main/resources/bootstrap.yml deleted file mode 100644 index 58281a4441..0000000000 --- a/spring-petclinic-customers-service/src/main/resources/bootstrap.yml +++ /dev/null @@ -1,14 +0,0 @@ -spring: - cloud: - config: - uri: http://localhost:8888 - application: - name: customers-service ---- -spring: - config: - activate: - on-profile: docker - cloud: - config: - uri: http://config-server:8888 diff --git a/spring-petclinic-discovery-server/src/main/resources/bootstrap.yml b/spring-petclinic-discovery-server/src/main/resources/bootstrap.yml deleted file mode 100644 index eba87c89e9..0000000000 --- a/spring-petclinic-discovery-server/src/main/resources/bootstrap.yml +++ /dev/null @@ -1,14 +0,0 @@ -spring: - cloud: - config: - uri: http://localhost:8888 - application: - name: discovery-server ---- -spring: - config: - activate: - on-profile: docker - cloud: - config: - uri: http://config-server:8888 diff --git a/spring-petclinic-vets-service/src/main/resources/bootstrap.yml b/spring-petclinic-vets-service/src/main/resources/bootstrap.yml deleted file mode 100644 index bc2f683e5e..0000000000 --- a/spring-petclinic-vets-service/src/main/resources/bootstrap.yml +++ /dev/null @@ -1,14 +0,0 @@ -spring: - cloud: - config: - uri: http://localhost:8888 - application: - name: vets-service ---- -spring: - config: - activate: - on-profile: docker - cloud: - config: - uri: http://config-server:8888 diff --git a/spring-petclinic-visits-service/src/main/resources/bootstrap.yml b/spring-petclinic-visits-service/src/main/resources/bootstrap.yml deleted file mode 100644 index 92f4fcae36..0000000000 --- a/spring-petclinic-visits-service/src/main/resources/bootstrap.yml +++ /dev/null @@ -1,14 +0,0 @@ -spring: - cloud: - config: - uri: http://localhost:8888 - application: - name: visits-service ---- -spring: - config: - activate: - on-profile: docker - cloud: - config: - uri: http://config-server:8888 From 2509c337e9698cc03510dd9f57842e66d8b174fb Mon Sep 17 00:00:00 2001 From: felipmiguel Date: Wed, 30 Nov 2022 22:37:38 +0100 Subject: [PATCH 19/22] springboot 2.6.11 cloud 2021.0.5 --- pom.xml | 10 +++++----- spring-petclinic-admin-server/pom.xml | 2 +- spring-petclinic-api-gateway/pom.xml | 2 +- spring-petclinic-config-server/pom.xml | 2 +- spring-petclinic-customers-service/pom.xml | 2 +- spring-petclinic-discovery-server/pom.xml | 2 +- spring-petclinic-vets-service/pom.xml | 2 +- spring-petclinic-visits-service/pom.xml | 2 +- 8 files changed, 12 insertions(+), 12 deletions(-) diff --git a/pom.xml b/pom.xml index f6d44aaf7f..9002e462a5 100644 --- a/pom.xml +++ b/pom.xml @@ -6,12 +6,12 @@ org.springframework.boot spring-boot-starter-parent - 2.6.11 + 2.7.6 org.springframework.samples spring-petclinic-microservices - 2.6.11 + 2.7.6 ${project.artifactId} pom @@ -29,9 +29,9 @@ 1.8 3.17.1 - 2.6.0 - 2021.0.2 - 2.3.10 + + 2021.0.5 + 2.6.1 springcommunity 9090 diff --git a/spring-petclinic-admin-server/pom.xml b/spring-petclinic-admin-server/pom.xml index 16c696fc8e..07c1334cfc 100644 --- a/spring-petclinic-admin-server/pom.xml +++ b/spring-petclinic-admin-server/pom.xml @@ -12,7 +12,7 @@ org.springframework.samples spring-petclinic-microservices - 2.6.11 + 2.7.6 diff --git a/spring-petclinic-api-gateway/pom.xml b/spring-petclinic-api-gateway/pom.xml index 5c7c014944..bb89ea00cd 100644 --- a/spring-petclinic-api-gateway/pom.xml +++ b/spring-petclinic-api-gateway/pom.xml @@ -11,7 +11,7 @@ org.springframework.samples spring-petclinic-microservices - 2.6.11 + 2.7.6 diff --git a/spring-petclinic-config-server/pom.xml b/spring-petclinic-config-server/pom.xml index 17748522c2..cca4c4983e 100644 --- a/spring-petclinic-config-server/pom.xml +++ b/spring-petclinic-config-server/pom.xml @@ -11,7 +11,7 @@ org.springframework.samples spring-petclinic-microservices - 2.6.11 + 2.7.6 diff --git a/spring-petclinic-customers-service/pom.xml b/spring-petclinic-customers-service/pom.xml index 82baa5bd5b..0eda0638d0 100644 --- a/spring-petclinic-customers-service/pom.xml +++ b/spring-petclinic-customers-service/pom.xml @@ -11,7 +11,7 @@ org.springframework.samples spring-petclinic-microservices - 2.6.11 + 2.7.6 diff --git a/spring-petclinic-discovery-server/pom.xml b/spring-petclinic-discovery-server/pom.xml index 60a7865c6f..24766267c2 100644 --- a/spring-petclinic-discovery-server/pom.xml +++ b/spring-petclinic-discovery-server/pom.xml @@ -11,7 +11,7 @@ org.springframework.samples spring-petclinic-microservices - 2.6.11 + 2.7.6 diff --git a/spring-petclinic-vets-service/pom.xml b/spring-petclinic-vets-service/pom.xml index 9b155f2ddf..81c124a0ec 100644 --- a/spring-petclinic-vets-service/pom.xml +++ b/spring-petclinic-vets-service/pom.xml @@ -11,7 +11,7 @@ org.springframework.samples spring-petclinic-microservices - 2.6.11 + 2.7.6 diff --git a/spring-petclinic-visits-service/pom.xml b/spring-petclinic-visits-service/pom.xml index dd53f32777..9709ca389f 100644 --- a/spring-petclinic-visits-service/pom.xml +++ b/spring-petclinic-visits-service/pom.xml @@ -12,7 +12,7 @@ org.springframework.samples spring-petclinic-microservices - 2.6.11 + 2.7.6 From 2b50635e59cede607acd3b211db1594d878ac04a Mon Sep 17 00:00:00 2001 From: felipmiguel Date: Wed, 30 Nov 2022 22:38:54 +0100 Subject: [PATCH 20/22] fix docker-compose to run locally --- docker-compose.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docker-compose.yml b/docker-compose.yml index c064485825..600ad71456 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -28,6 +28,8 @@ services: entrypoint: ["./dockerize","-wait=tcp://discovery-server:8761","-timeout=60s","--","java", "org.springframework.boot.loader.JarLauncher"] ports: - 8081:8081 + environment: + - SERVER_PORT=8081 visits-service: image: springcommunity/spring-petclinic-visits-service @@ -39,6 +41,8 @@ services: entrypoint: ["./dockerize","-wait=tcp://discovery-server:8761","-timeout=60s","--","java", "org.springframework.boot.loader.JarLauncher"] ports: - 8082:8082 + environment: + - SERVER_PORT=8082 vets-service: image: springcommunity/spring-petclinic-vets-service @@ -50,6 +54,9 @@ services: entrypoint: ["./dockerize","-wait=tcp://discovery-server:8761","-timeout=60s","--","java", "org.springframework.boot.loader.JarLauncher"] ports: - 8083:8083 + environment: + - SERVER_PORT=8083 + api-gateway: image: springcommunity/spring-petclinic-api-gateway @@ -62,6 +69,7 @@ services: ports: - 8080:8080 + tracing-server: image: openzipkin/zipkin container_name: tracing-server From 9656f6354d003c4299417108f4f7d26d6ddc5ee8 Mon Sep 17 00:00:00 2001 From: felipmiguel Date: Tue, 10 Jan 2023 17:39:15 +0100 Subject: [PATCH 21/22] upgrade 2.7.6 + passwordless --- README.md | 35 ++++++++----------- pom.xml | 8 +++++ spring-petclinic-customers-service/pom.xml | 6 ++++ .../src/main/resources/schema-mysql.sql | 6 ++-- spring-petclinic-vets-service/pom.xml | 6 ++++ .../src/main/resources/schema-mysql.sql | 6 ++-- spring-petclinic-visits-service/pom.xml | 6 ++++ .../src/main/resources/schema-mysql.sql | 6 ++-- 8 files changed, 49 insertions(+), 30 deletions(-) diff --git a/README.md b/README.md index dba91658fe..2c884fd9b8 100644 --- a/README.md +++ b/README.md @@ -39,16 +39,11 @@ You will: ## What you will need -In order to deploy a Java app to cloud, you need -an Azure subscription. If you do not already have an Azure -subscription, you can activate your -[MSDN subscriber benefits](https://azure.microsoft.com/pricing/member-offers/msdn-benefits-details/) -or sign up for a -[free Azure account]((https://azure.microsoft.com/free/)). +In order to deploy a Java app to cloud, you need an Azure subscription. If you do not already have an Azure subscription, you can activate your [MSDN subscriber benefits](https://azure.microsoft.com/pricing/member-offers/msdn-benefits-details/) or sign up for a [free Azure account]((https://azure.microsoft.com/free/)). In addition, you will need the following: -| [Azure CLI version 2.17.1 or higher](https://docs.microsoft.com/cli/azure/install-azure-cli?view=azure-cli-latest) +| [Azure CLI version 2.44.0 or higher](https://docs.microsoft.com/cli/azure/install-azure-cli?view=azure-cli-latest) | [Java 8](https://www.azul.com/downloads/azure-only/zulu/?version=java-8-lts&architecture=x86-64-bit&package=jdk) | [Maven](https://maven.apache.org/download.cgi) | [MySQL CLI](https://dev.mysql.com/downloads/shell/) @@ -92,12 +87,10 @@ Install the Azure Spring Cloud extension for the Azure CLI using the following c ```bash az extension add --name spring-cloud ``` -Note - `spring-cloud` CLI extension `2.1.0` or later is a pre-requisite to enable the -latest Java in-process agent for Application Insights. If you already -have the CLI extension, you may need to upgrade to the latest using -- +Note - `spring` CLI extension `1.5.0` or later is a pre-requisite to enable the latest Java in-process agent for Application Insights. If you already have the CLI extension, you may need to upgrade to the latest using -- ```bash - az extension update --name spring-cloud + az extension update --name spring ``` ## Clone and build the repo @@ -171,7 +164,7 @@ Create a resource group to contain your Azure Spring Cloud service. Create an instance of Azure Spring Cloud. ```bash - az spring-cloud create --name ${SPRING_CLOUD_SERVICE} \ + az spring create --name ${SPRING_CLOUD_SERVICE} \ --sku standard \ --sampling-rate 100 \ --resource-group ${RESOURCE_GROUP} \ @@ -186,7 +179,7 @@ Set your default resource group name and cluster name using the following comman az configure --defaults \ group=${RESOURCE_GROUP} \ location=${REGION} \ - spring-cloud=${SPRING_CLOUD_SERVICE} + spring=${SPRING_CLOUD_SERVICE} ``` ### Create and configure Log Analytics Workspace @@ -252,38 +245,38 @@ Setup diagnostics and publish logs and metrics from Spring Boot apps to Azure Lo ]' ``` -### Load Spring Cloud Config Server +### Load Spring Apps Config Server Use the `application.yml` in the root of this project to load configuration into the Config Server in Azure Spring Cloud. ```bash - az spring-cloud config-server set \ + az spring config-server set \ --config-file application.yml \ --name ${SPRING_CLOUD_SERVICE} ``` -### Create applications in Azure Spring Cloud +### Create applications in Azure Spring Apps Create 5 apps. ```bash - az spring-cloud app create --name ${API_GATEWAY} --instance-count 1 --assign-endpoint true \ + az spring app create --name ${API_GATEWAY} --instance-count 1 --assign-endpoint true \ --memory 2 \ --jvm-options='-Xms2048m -Xmx2048m' - az spring-cloud app create --name ${ADMIN_SERVER} --instance-count 1 --assign-endpoint true \ + az spring app create --name ${ADMIN_SERVER} --instance-count 1 --assign-endpoint true \ --memory 2 \ --jvm-options='-Xms2048m -Xmx2048m' - az spring-cloud app create --name ${CUSTOMERS_SERVICE} --instance-count 1 \ + az spring app create --name ${CUSTOMERS_SERVICE} --instance-count 1 \ --memory 2 \ --jvm-options='-Xms2048m -Xmx2048m' - az spring-cloud app create --name ${VETS_SERVICE} --instance-count 1 \ + az spring app create --name ${VETS_SERVICE} --instance-count 1 \ --memory 2 \ --jvm-options='-Xms2048m -Xmx2048m' - az spring-cloud app create --name ${VISITS_SERVICE} --instance-count 1 \ + az spring app create --name ${VISITS_SERVICE} --instance-count 1 \ --memory 2 \ --jvm-options='-Xms2048m -Xmx2048m' ``` diff --git a/pom.xml b/pom.xml index 9002e462a5..1065e4753a 100644 --- a/pom.xml +++ b/pom.xml @@ -38,6 +38,7 @@ ${basedir} v0.6.1 1.2.0 + 4.5.0 @@ -60,6 +61,13 @@ ${assertj.version} test
+ + com.azure.spring + spring-cloud-azure-dependencies + ${version.spring.cloud.azure} + pom + import +
diff --git a/spring-petclinic-customers-service/pom.xml b/spring-petclinic-customers-service/pom.xml index 0eda0638d0..55109e26dd 100644 --- a/spring-petclinic-customers-service/pom.xml +++ b/spring-petclinic-customers-service/pom.xml @@ -63,6 +63,12 @@ --> + + + com.azure.spring + spring-cloud-azure-starter-jdbc-mysql + + mysql diff --git a/spring-petclinic-customers-service/src/main/resources/schema-mysql.sql b/spring-petclinic-customers-service/src/main/resources/schema-mysql.sql index 720913829a..67eb65fe48 100644 --- a/spring-petclinic-customers-service/src/main/resources/schema-mysql.sql +++ b/spring-petclinic-customers-service/src/main/resources/schema-mysql.sql @@ -1,7 +1,7 @@ -CREATE DATABASE IF NOT EXISTS petclinic; -GRANT ALL PRIVILEGES ON petclinic.* TO pc@localhost IDENTIFIED BY 'pc'; +-- CREATE DATABASE IF NOT EXISTS petclinic; +-- GRANT ALL PRIVILEGES ON petclinic.* TO pc@localhost IDENTIFIED BY 'pc'; -USE petclinic; +-- USE petclinic; CREATE TABLE IF NOT EXISTS types ( id INT(4) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, diff --git a/spring-petclinic-vets-service/pom.xml b/spring-petclinic-vets-service/pom.xml index 81c124a0ec..484d1984f0 100644 --- a/spring-petclinic-vets-service/pom.xml +++ b/spring-petclinic-vets-service/pom.xml @@ -74,6 +74,12 @@ --> + + + com.azure.spring + spring-cloud-azure-starter-jdbc-mysql + + org.projectlombok diff --git a/spring-petclinic-vets-service/src/main/resources/schema-mysql.sql b/spring-petclinic-vets-service/src/main/resources/schema-mysql.sql index 4f9af3d1bd..a4c847e533 100644 --- a/spring-petclinic-vets-service/src/main/resources/schema-mysql.sql +++ b/spring-petclinic-vets-service/src/main/resources/schema-mysql.sql @@ -1,7 +1,7 @@ -CREATE DATABASE IF NOT EXISTS petclinic; -GRANT ALL PRIVILEGES ON petclinic.* TO pc@localhost IDENTIFIED BY 'pc'; +-- CREATE DATABASE IF NOT EXISTS petclinic; +-- GRANT ALL PRIVILEGES ON petclinic.* TO pc@localhost IDENTIFIED BY 'pc'; -USE petclinic; +-- USE petclinic; CREATE TABLE IF NOT EXISTS vets ( id INT(4) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, diff --git a/spring-petclinic-visits-service/pom.xml b/spring-petclinic-visits-service/pom.xml index 9709ca389f..53e23d507b 100644 --- a/spring-petclinic-visits-service/pom.xml +++ b/spring-petclinic-visits-service/pom.xml @@ -64,6 +64,12 @@ --> + + + com.azure.spring + spring-cloud-azure-starter-jdbc-mysql + + org.projectlombok diff --git a/spring-petclinic-visits-service/src/main/resources/schema-mysql.sql b/spring-petclinic-visits-service/src/main/resources/schema-mysql.sql index 65c448c69c..c9e76dcb0c 100644 --- a/spring-petclinic-visits-service/src/main/resources/schema-mysql.sql +++ b/spring-petclinic-visits-service/src/main/resources/schema-mysql.sql @@ -1,7 +1,7 @@ -CREATE DATABASE IF NOT EXISTS petclinic; -GRANT ALL PRIVILEGES ON petclinic.* TO pc@localhost IDENTIFIED BY 'pc'; +-- CREATE DATABASE IF NOT EXISTS petclinic; +-- GRANT ALL PRIVILEGES ON petclinic.* TO pc@localhost IDENTIFIED BY 'pc'; -USE petclinic; +-- USE petclinic; CREATE TABLE IF NOT EXISTS visits ( id INT(4) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, From 4a7c9af767582b19ad6fc0a5415429c03d896491 Mon Sep 17 00:00:00 2001 From: felipmiguel Date: Tue, 10 Jan 2023 22:14:38 +0100 Subject: [PATCH 22/22] updated readme --- README.md | 367 +++++++++++++++++++++++++++++------------------------- 1 file changed, 194 insertions(+), 173 deletions(-) diff --git a/README.md b/README.md index 2c884fd9b8..485cb88f0a 100644 --- a/README.md +++ b/README.md @@ -3,20 +3,18 @@ page_type: sample languages: - java products: -- Azure Spring Cloud -description: "Deploy Spring Boot apps using Azure Spring Cloud and MySQL" +- Azure Spring Apps +description: "Deploy Spring Boot apps using Azure Spring Apps and MySQL" urlFragment: "spring-petclinic-microservices" --- -# Deploy Spring Boot apps using Azure Spring Cloud and MySQL +# Deploy Spring Boot apps using Azure Spring Apps and MySQL -Azure Spring Cloud enables you to easily run a Spring Boot applications on Azure. +Azure Spring Apps enables you to easily run a Spring Boot applications on Azure. -This quickstart shows you how to deploy an existing Java Spring Cloud application to Azure. When -you're finished, you can continue to manage the application via the Azure CLI or switch to using the -Azure Portal. +This quickstart shows you how to deploy an existing Java Spring Cloud application to Azure. When you're finished, you can continue to manage the application via the Azure CLI or switch to using the Azure Portal. -* [Deploy Spring Boot apps using Azure Spring Cloud and MySQL](#deploy-spring-boot-apps-using-azure-spring-cloud-and-mysql) +* [Deploy Spring Boot apps using Azure Spring Apps and MySQL](#deploy-spring-boot-apps-using-azure-spring-cloud-and-mysql) * [What will you experience](#what-will-you-experience) * [What you will need](#what-you-will-need) * [Install the Azure CLI extension](#install-the-azure-cli-extension) @@ -29,9 +27,9 @@ Azure Portal. ## What will you experience You will: - Build existing Spring Boot applications -- Provision an Azure Spring Cloud service instance. If you prefer Terraform, you may also provision using Terraform, see [`README-terraform`](./terraform/README-terraform.md) +- Provision an Azure Spring Apps service instance. If you prefer Terraform, you may also provision using Terraform, see [`README-terraform`](./terraform/README-terraform.md) - Deploy applications to Azure -- Bind applications to Azure Database for MySQL +- Connect applications to Azure Database for MySQL using Azure AD authentication - Open the application - Monitor applications - Automate deployments using GitHub Actions @@ -44,22 +42,14 @@ In order to deploy a Java app to cloud, you need an Azure subscription. If you d In addition, you will need the following: | [Azure CLI version 2.44.0 or higher](https://docs.microsoft.com/cli/azure/install-azure-cli?view=azure-cli-latest) -| [Java 8](https://www.azul.com/downloads/azure-only/zulu/?version=java-8-lts&architecture=x86-64-bit&package=jdk) +| [Java 8](https://adoptium.net/temurin/releases/?version=8) | [Maven](https://maven.apache.org/download.cgi) -| [MySQL CLI](https://dev.mysql.com/downloads/shell/) | [Git](https://git-scm.com/) -| [`jq` utility](https://stedolan.github.io/jq/download/) | -Note - The [`jq` utility](https://stedolan.github.io/jq/download/). On Windows, download [this Windows port of JQ](https://github.com/stedolan/jq/releases) and add the following to the `~/.bashrc` file: - ```bash - alias jq=/jq-win64.exe - ``` - -Note - The Bash shell. While Azure CLI should behave identically on all environments, shell +> Note - The Bash shell. While Azure CLI should behave identically on all environments, shell semantics vary. Therefore, only bash can be used with the commands in this repo. To complete these repo steps on Windows, use Git Bash that accompanies the Windows distribution of -Git. Use only Git Bash to complete this training on Windows. Do not use WSL. ### OR Use Azure Cloud Shell @@ -82,10 +72,10 @@ To run the code in this article in Azure Cloud Shell: ## Install the Azure CLI extension -Install the Azure Spring Cloud extension for the Azure CLI using the following command +Install the Azure Spring extension for the Azure CLI using the following command ```bash - az extension add --name spring-cloud + az extension add --name spring ``` Note - `spring` CLI extension `1.5.0` or later is a pre-requisite to enable the latest Java in-process agent for Application Insights. If you already have the CLI extension, you may need to upgrade to the latest using -- @@ -123,7 +113,6 @@ Create a bash script with environment variables by making a copy of the supplied Open `.scripts/setup-env-variables-azure.sh` and enter the following information: ```bash - export SUBSCRIPTION=subscription-id # customize this export RESOURCE_GROUP=resource-group-name # customize this ... @@ -138,12 +127,14 @@ Open `.scripts/setup-env-variables-azure.sh` and enter the following information ``` Then, set the environment: + ```bash source .scripts/setup-env-variables-azure.sh ``` -### Login to Azure -Login to the Azure CLI and choose your active subscription. Be sure to choose the active subscription that is whitelisted for Azure Spring Cloud +### Login to Azure + +Login to the Azure CLI and choose your active subscription. Be sure to choose the active subscription that is whitelisted for Azure Spring Apps ```bash az login @@ -151,17 +142,18 @@ Login to the Azure CLI and choose your active subscription. Be sure to choose th az account set --subscription ${SUBSCRIPTION} ``` -### Create Azure Spring Cloud service instance -Prepare a name for your Azure Spring Cloud service. The name must be between 4 and 32 characters long and can contain only lowercase letters, numbers, and hyphens. The first character of the service name must be a letter and the last character must be either a letter or a number. +### Create Azure Spring App service instance -Create a resource group to contain your Azure Spring Cloud service. +Prepare a name for your Azure Spring App service. The name must be between 4 and 32 characters long and can contain only lowercase letters, numbers, and hyphens. The first character of the service name must be a letter and the last character must be either a letter or a number. + +Create a resource group to contain your Azure Spring App service. ```bash az group create --name ${RESOURCE_GROUP} \ --location ${REGION} ``` -Create an instance of Azure Spring Cloud. +Create an instance of Azure Spring App. ```bash az spring create --name ${SPRING_CLOUD_SERVICE} \ @@ -194,11 +186,15 @@ Create a Log Analytics Workspace using Azure CLI: export LOG_ANALYTICS_RESOURCE_ID=$(az monitor log-analytics workspace show \ --resource-group ${RESOURCE_GROUP} \ - --workspace-name ${LOG_ANALYTICS} | jq -r '.id') + --workspace-name ${LOG_ANALYTICS} \ + --query 'id' \ + --output tsv) - export SPRING_CLOUD_RESOURCE_ID=$(az spring-cloud show \ + export SPRING_CLOUD_RESOURCE_ID=$(az spring show \ --name ${SPRING_CLOUD_SERVICE} \ - --resource-group ${RESOURCE_GROUP} | jq -r '.id') + --resource-group ${RESOURCE_GROUP} \ + --query 'id' \ + --output tsv) ``` Setup diagnostics and publish logs and metrics from Spring Boot apps to Azure Log Analytics: @@ -247,7 +243,7 @@ Setup diagnostics and publish logs and metrics from Spring Boot apps to Azure Lo ### Load Spring Apps Config Server -Use the `application.yml` in the root of this project to load configuration into the Config Server in Azure Spring Cloud. +Use the `application.yml` in the root of this project to load configuration into the Config Server in Azure Spring Apps. ```bash az spring config-server set \ @@ -261,23 +257,23 @@ Create 5 apps. ```bash az spring app create --name ${API_GATEWAY} --instance-count 1 --assign-endpoint true \ - --memory 2 \ + --memory 2Gi \ --jvm-options='-Xms2048m -Xmx2048m' az spring app create --name ${ADMIN_SERVER} --instance-count 1 --assign-endpoint true \ - --memory 2 \ + --memory 2Gi \ --jvm-options='-Xms2048m -Xmx2048m' az spring app create --name ${CUSTOMERS_SERVICE} --instance-count 1 \ - --memory 2 \ + --memory 2Gi \ --jvm-options='-Xms2048m -Xmx2048m' az spring app create --name ${VETS_SERVICE} --instance-count 1 \ - --memory 2 \ + --memory 2Gi \ --jvm-options='-Xms2048m -Xmx2048m' az spring app create --name ${VISITS_SERVICE} --instance-count 1 \ - --memory 2 \ + --memory 2Gi \ --jvm-options='-Xms2048m -Xmx2048m' ``` @@ -286,72 +282,91 @@ Create 5 apps. Create a MySQL database in Azure Database for MySQL. ```bash - // create mysql server - az mysql server create --resource-group ${RESOURCE_GROUP} \ - --name ${MYSQL_SERVER_NAME} --location ${REGION} \ - --admin-user ${MYSQL_SERVER_ADMIN_NAME} \ - --admin-password ${MYSQL_SERVER_ADMIN_PASSWORD} \ - --sku-name GP_Gen5_2 \ - --ssl-enforcement Disabled \ - --version 5.7 - - // allow access from Azure resources - az mysql server firewall-rule create --name allAzureIPs \ - --server ${MYSQL_SERVER_NAME} \ - --resource-group ${RESOURCE_GROUP} \ - --start-ip-address 0.0.0.0 --end-ip-address 0.0.0.0 + // create mysql server and provide access from Azure resources + az mysql flexible-server create \ + --name ${MYSQL_SERVER_NAME} \ + --resource-group ${RESOURCE_GROUP} \ + --location ${REGION} \ + --admin-user ${MYSQL_SERVER_ADMIN_NAME} \ + --admin-password ${MYSQL_SERVER_ADMIN_PASSWORD} \ + --public-access 0.0.0.0 \ + --tier Burstable \ + --sku-name Standard_B1ms \ + --storage-size 32 // allow access from your dev machine for testing - az mysql server firewall-rule create --name devMachine \ - --server ${MYSQL_SERVER_NAME} \ - --resource-group ${RESOURCE_GROUP} \ - --start-ip-address \ - --end-ip-address - - // increase connection timeout - az mysql server configuration set --name wait_timeout \ - --resource-group ${RESOURCE_GROUP} \ - --server ${MYSQL_SERVER_NAME} --value 2147483 - - // SUBSTITUTE values - mysql -u ${MYSQL_SERVER_ADMIN_LOGIN_NAME} \ - -h ${MYSQL_SERVER_FULL_NAME} -P 3306 -p - - Enter password: - Welcome to the MySQL monitor. Commands end with ; or \g. - Your MySQL connection id is 64379 - Server version: 5.6.39.0 MySQL Community Server (GPL) - - Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. - - Oracle is a registered trademark of Oracle Corporation and/or its - affiliates. Other names may be trademarks of their respective - owners. - - Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. - - mysql> CREATE DATABASE petclinic; - Query OK, 1 row affected (0.10 sec) - - mysql> CREATE USER 'root' IDENTIFIED BY 'petclinic'; - Query OK, 0 rows affected (0.11 sec) + MY_IP=$(curl http://whatismyip.akamai.com) + az mysql flexible-server firewall-rule create \ + --resource-group ${RESOURCE_GROUP} \ + --name ${MYSQL_SERVER_NAME} \ + --rule-name devMachine \ + --start-ip-address ${MY_IP} \ + --end-ip-address ${MY_IP} - mysql> GRANT ALL PRIVILEGES ON petclinic.* TO 'root'; - Query OK, 0 rows affected (1.29 sec) + // create database + az mysql flexible-server db create \ + --resource-group ${RESOURCE_GROUP} \ + --server-name ${MYSQL_SERVER_NAME} \ + --database-name ${MYSQL_DATABASE_NAME} - mysql> CALL mysql.az_load_timezone(); - Query OK, 3179 rows affected, 1 warning (6.34 sec) + // increase connection timeout + az mysql flexible-server parameter set \ + --resource-group ${RESOURCE_GROUP} \ + --server ${MYSQL_SERVER_NAME} \ + --name wait_timeout \ + --value 2147483 - mysql> SELECT name FROM mysql.time_zone_name; - ... - mysql> quit - Bye + az mysql flexible-server parameter set \ + --resource-group ${RESOURCE_GROUP} \ + --server ${MYSQL_SERVER_NAME} \ + --name time_zone \ + --value "US/Pacific" - az mysql server configuration set --name time_zone \ - --resource-group ${RESOURCE_GROUP} \ - --server ${MYSQL_SERVER_NAME} --value "US/Pacific" + # create managed identity for mysql. By assigning the identity to the mysql server, it will enable Azure AD authentication + az identity create \ + --name ${MYSQL_IDENTITY} \ + --resource-group ${RESOURCE_GROUP} \ + --location ${REGION} + + IDENTITY_ID=$(az identity show --name ${MYSQL_IDENTITY} --resource-group ${RESOURCE_GROUP} --query id -o tsv) + + // Customer service connection + az spring connection create mysql-flexible \ + --resource-group ${RESOURCE_GROUP} \ + --service ${SPRING_CLOUD_SERVICE} \ + --app ${CUSTOMERS_SERVICE} \ + --deployment default \ + --tg ${RESOURCE_GROUP} \ + --server ${MYSQL_SERVER_NAME} \ + --database ${MYSQL_DATABASE_NAME} \ + --system-identity mysql-identity-id=$IDENTITY_ID \ + --client-type springboot + + // Vets service connection + az spring connection create mysql-flexible \ + --resource-group ${RESOURCE_GROUP} \ + --service ${SPRING_CLOUD_SERVICE} \ + --app ${VETS_SERVICE} \ + --deployment default \ + --tg ${RESOURCE_GROUP} \ + --server ${MYSQL_SERVER_NAME} \ + --database ${MYSQL_DATABASE_NAME} \ + --system-identity mysql-identity-id=$IDENTITY_ID \ + --client-type springboot + + // Visits service connection + az spring connection create mysql-flexible \ + --resource-group ${RESOURCE_GROUP} \ + --service ${SPRING_CLOUD_SERVICE} \ + --app ${VISITS_SERVICE} \ + --deployment default \ + --tg ${RESOURCE_GROUP} \ + --server ${MYSQL_SERVER_NAME} \ + --database ${MYSQL_DATABASE_NAME} \ + --system-identity mysql-identity-id=$IDENTITY_ID \ + --client-type springboot ``` ### Deploy Spring Boot applications and set environment variables @@ -359,45 +374,50 @@ Create a MySQL database in Azure Database for MySQL. Deploy Spring Boot applications to Azure. ```bash - az spring-cloud app deploy --name ${API_GATEWAY} \ - --jar-path ${API_GATEWAY_JAR} \ - --jvm-options='-Xms2048m -Xmx2048m -Dspring.profiles.active=mysql' - - - az spring-cloud app deploy --name ${ADMIN_SERVER} \ - --jar-path ${ADMIN_SERVER_JAR} \ - --jvm-options='-Xms2048m -Xmx2048m -Dspring.profiles.active=mysql' - - - az spring-cloud app deploy --name ${CUSTOMERS_SERVICE} \ - --jar-path ${CUSTOMERS_SERVICE_JAR} \ - --jvm-options='-Xms2048m -Xmx2048m -Dspring.profiles.active=mysql' \ - --env MYSQL_SERVER_FULL_NAME=${MYSQL_SERVER_FULL_NAME} \ - MYSQL_DATABASE_NAME=${MYSQL_DATABASE_NAME} \ - MYSQL_SERVER_ADMIN_LOGIN_NAME=${MYSQL_SERVER_ADMIN_LOGIN_NAME} \ - MYSQL_SERVER_ADMIN_PASSWORD=${MYSQL_SERVER_ADMIN_PASSWORD} - - - az spring-cloud app deploy --name ${VETS_SERVICE} \ - --jar-path ${VETS_SERVICE_JAR} \ - --jvm-options='-Xms2048m -Xmx2048m -Dspring.profiles.active=mysql' \ - --env MYSQL_SERVER_FULL_NAME=${MYSQL_SERVER_FULL_NAME} \ - MYSQL_DATABASE_NAME=${MYSQL_DATABASE_NAME} \ - MYSQL_SERVER_ADMIN_LOGIN_NAME=${MYSQL_SERVER_ADMIN_LOGIN_NAME} \ - MYSQL_SERVER_ADMIN_PASSWORD=${MYSQL_SERVER_ADMIN_PASSWORD} - - - az spring-cloud app deploy --name ${VISITS_SERVICE} \ - --jar-path ${VISITS_SERVICE_JAR} \ - --jvm-options='-Xms2048m -Xmx2048m -Dspring.profiles.active=mysql' \ - --env MYSQL_SERVER_FULL_NAME=${MYSQL_SERVER_FULL_NAME} \ - MYSQL_DATABASE_NAME=${MYSQL_DATABASE_NAME} \ - MYSQL_SERVER_ADMIN_LOGIN_NAME=${MYSQL_SERVER_ADMIN_LOGIN_NAME} \ - MYSQL_SERVER_ADMIN_PASSWORD=${MYSQL_SERVER_ADMIN_PASSWORD} + az spring app deploy \ + --resource-group ${RESOURCE_GROUP} \ + --service ${SPRING_CLOUD_SERVICE} \ + --name ${API_GATEWAY} \ + --artifact-path ${API_GATEWAY_JAR} \ + --jvm-options='-Xms2048m -Xmx2048m' \ + --env SPRING_PROFILES_ACTIVE=passwordless + +az spring app deploy \ + --resource-group ${RESOURCE_GROUP} \ + --service ${SPRING_CLOUD_SERVICE} \ + --name ${ADMIN_SERVER} \ + --artifact-path ${ADMIN_SERVER_JAR} \ + --jvm-options='-Xms2048m -Xmx2048m' \ + --env SPRING_PROFILES_ACTIVE=passwordless + + +az spring app deploy \ + --resource-group ${RESOURCE_GROUP} \ + --service ${SPRING_CLOUD_SERVICE} \ + --name ${CUSTOMERS_SERVICE} \ + --artifact-path ${CUSTOMERS_SERVICE_JAR} \ + --jvm-options='-Xms2048m -Xmx2048m' \ + --env SPRING_PROFILES_ACTIVE=passwordless + +az spring app deploy \ + --resource-group ${RESOURCE_GROUP} \ + --service ${SPRING_CLOUD_SERVICE} \ + --name ${VETS_SERVICE} \ + --artifact-path ${VETS_SERVICE_JAR} \ + --jvm-options='-Xms2048m -Xmx2048m' \ + --env SPRING_PROFILES_ACTIVE=passwordless + +az spring app deploy \ + --resource-group ${RESOURCE_GROUP} \ + --service ${SPRING_CLOUD_SERVICE} \ + --name ${VISITS_SERVICE} \ + --artifact-path ${VISITS_SERVICE_JAR} \ + --jvm-options='-Xms2048m -Xmx2048m' \ + --env SPRING_PROFILES_ACTIVE=passwordless ``` ```bash - az spring-cloud app show --name ${API_GATEWAY} | grep url + az spring app show --name ${API_GATEWAY} --query properties.url --output tsv ``` Navigate to the URL provided by the previous command to open the Pet Clinic application. @@ -433,15 +453,16 @@ curl -X GET https://${SPRING_CLOUD_SERVICE}-${API_GATEWAY}.azuremicroservices.io #### Get the log stream for API Gateway and Customers Service -Use the following command to get the latest 100 lines of app console logs from Customers Service. +Use the following command to get the latest 100 lines of app console logs from Customers Service. + ```bash -az spring-cloud app logs -n ${CUSTOMERS_SERVICE} --lines 100 +az spring app logs -n ${CUSTOMERS_SERVICE} --lines 100 ``` By adding a `-f` parameter you can get real-time log streaming from the app. Try log streaming for the API Gateway app. ```bash -az spring-cloud app logs -n ${API_GATEWAY} -f +az spring app logs -n ${API_GATEWAY} -f ``` -You can use `az spring-cloud app logs -h` to explore more parameters and log stream functionalities. +You can use `az spring app logs -h` to explore more parameters and log stream functionalities. #### Open Actuator endpoints for API Gateway and Customers Service apps @@ -463,9 +484,8 @@ open https://${SPRING_CLOUD_SERVICE}-${API_GATEWAY}.azuremicroservices.io/api/cu #### Start monitoring Spring Boot apps and dependencies - in Application Insights -Open the Application Insights created by Azure Spring Cloud and start monitoring -Spring Boot applications. You can find the Application Insights in the same Resource Group where -you created an Azure Spring Cloud service instance. +Open the Application Insights created by Azure Spring Apps and start monitoring Spring Boot applications. You can find the Application Insights in the same Resource Group where +you created an Azure Spring Apps service instance. Navigate to the `Application Map` blade: ![](./media/distributed-tracking-new-ai-agent.jpg) @@ -506,7 +526,7 @@ All those three REST controllers `OwnerResource`, `PetResource` and `VisitResour You can see these custom metrics in the `Metrics` blade: ![](./media/petclinic-microservices-custom-metrics.jpg) -You can use the Availability Test feature in Application Insights and monitor +You can use the Availability Test feature in Application Insights and monitor the availability of applications: ![](./media/petclinic-microservices-availability.jpg) @@ -516,10 +536,10 @@ Navigate to the `Live Metrics` blade - you can see live metrics on screen with l #### Start monitoring Petclinic logs and metrics in Azure Log Analytics Open the Log Analytics that you created - you can find the Log Analytics in the same -Resource Group where you created an Azure Spring Cloud service instance. +Resource Group where you created an Azure Spring Apps service instance. In the Log Analyics page, selects `Logs` blade and run any of the sample queries supplied below -for Azure Spring Cloud. +for Azure Spring Apps. Type and run the following Kusto query to see application logs: ```sql @@ -547,7 +567,7 @@ Type and run the following Kusto query to see errors and exceptions thrown by e | render piechart ``` -Type and run the following Kusto query to see all in the inbound calls into Azure Spring Cloud: +Type and run the following Kusto query to see all in the inbound calls into Azure Spring Apps: ```sql AppPlatformIngressLogs | project TimeGenerated, RemoteAddr, Host, Request, Status, BodyBytesSent, RequestTime, ReqId, RequestHeaders @@ -555,7 +575,7 @@ Type and run the following Kusto query to see all in the inbound calls into Azur ``` Type and run the following Kusto query to see all the logs from the managed Spring Cloud -Config Server managed by Azure Spring Cloud: +Config Server managed by Azure Spring Apps: ```sql AppPlatformSystemLogs | where LogType contains "ConfigServer" @@ -564,7 +584,7 @@ Config Server managed by Azure Spring Cloud: ``` Type and run the following Kusto query to see all the logs from the managed Spring Cloud -Service Registry managed by Azure Spring Cloud: +Service Registry managed by Azure Spring Apps: ```sql AppPlatformSystemLogs | where LogType contains "ServiceRegistry" @@ -575,7 +595,7 @@ Service Registry managed by Azure Spring Cloud: ## Unit-2 - Automate deployments using GitHub Actions ### Prerequisites To get started with deploying this sample app from GitHub Actions, please: -1. Complete the sections above with your MySQL, Azure Spring Cloud instances and apps created. +1. Complete the sections above with your MySQL, Azure Spring Apps instances and apps created. 2. Fork this repository and turn on GitHub Actions in your fork ### Prepare secrets in your Key Vault @@ -592,7 +612,7 @@ Add the MySQL secrets to your Key Vault: az keyvault secret set --vault-name ${KEY_VAULT} --name "MYSQL-SERVER-ADMIN-PASSWORD" --value ${MYSQL_SERVER_ADMIN_PASSWORD} ``` -Create a service principle with enough scope/role to manage your Azure Spring Cloud instance: +Create a service principle with enough scope/role to manage your Azure Spring Apps instance: ```bash az ad sp create-for-rbac --role contributor --scopes /subscriptions/${SUBSCRIPTION} --sdk-auth ``` @@ -620,19 +640,19 @@ To generate a key to access the Key Vault, execute command below: ```bash az ad sp create-for-rbac --role contributor --scopes /subscriptions/${SUBSCRIPTION}/resourceGroups/${RESOURCE_GROUP}/providers/Microsoft.KeyVault/vaults/${KEY_VAULT} --sdk-auth ``` -Then, follow [the steps here](https://docs.microsoft.com/azure/spring-cloud/spring-cloud-github-actions-key-vault#add-access-policies-for-the-credential) to add access policy for the Service Principal. +Then, follow [the steps here](https://learn.microsoft.com/azure/spring-apps/github-actions-key-vault#add-access-policies-for-the-credential) to add access policy for the Service Principal. -In the end, add this service principal as secret named "AZURE_CREDENTIALS" in your forked GitHub repo following [the steps here](https://docs.microsoft.com/azure/spring-cloud/how-to-github-actions?pivots=programming-language-java#set-up-github-repository-and-authenticate-1). +In the end, add this service principal as secret named "AZURE_CREDENTIALS" in your forked GitHub repo following [the steps here](https://learn.microsoft.com/azure/spring-apps/how-to-github-actions?pivots=programming-language-java#set-up-github-repository-and-authenticate-1). ### Customize your workflow -Finally, edit the workflow file `.github/workflows/action.yml` in your forked repo to fill in the subscription ID, Azure Spring Cloud instance name, and Key Vault name that you just created: +Finally, edit the workflow file `.github/workflows/action.yml` in your forked repo to fill in the subscription ID, Azure Spring Apps instance name, and Key Vault name that you just created: ```yml env: AZURE_SUBSCRIPTION: subscription-id # customize this SPRING_CLOUD_SERVICE: azure-spring-cloud-name # customize this KEYVAULT: your-keyvault-name # customize this ``` -Once you push this change, you will see GitHub Actions triggered to build and deploy all the apps in the repo to your Azure Spring Cloud instance. +Once you push this change, you will see GitHub Actions triggered to build and deploy all the apps in the repo to your Azure Spring Apps instance. ![](./media/automate-deployments-using-github-actions.png) ## Unit-3 - Manage application secrets using Azure KeyVault @@ -645,7 +665,7 @@ If you skipped the [Automation step](#automate-deployments-using-github-actions) ```bash az keyvault create --name ${KEY_VAULT} -g ${RESOURCE_GROUP} - export KEY_VAULT_URI=$(az keyvault show --name ${KEY_VAULT} | jq -r '.properties.vaultUri') + export KEY_VAULT_URI=$(az keyvault show --name ${KEY_VAULT} --query 'properties.vaultUri' --output tsv) ``` Store database connection secrets in Key Vault. @@ -664,19 +684,19 @@ Store database connection secrets in Key Vault. --name "MYSQL-SERVER-ADMIN-PASSWORD" --value ${MYSQL_SERVER_ADMIN_PASSWORD} ``` -### Enable Managed Identities for applications in Azure Spring Cloud +### Enable Managed Identities for applications in Azure Spring Apps Enable System Assigned Identities for applications and export identities to environment. ```bash - az spring-cloud app identity assign --name ${CUSTOMERS_SERVICE} - export CUSTOMERS_SERVICE_IDENTITY=$(az spring-cloud app show --name ${CUSTOMERS_SERVICE} | jq -r '.identity.principalId') + az spring app identity assign --name ${CUSTOMERS_SERVICE} + export CUSTOMERS_SERVICE_IDENTITY=$(az spring app show --name ${CUSTOMERS_SERVICE} --query 'identity.principalId' --output tsv) - az spring-cloud app identity assign --name ${VETS_SERVICE} - export VETS_SERVICE_IDENTITY=$(az spring-cloud app show --name ${VETS_SERVICE} | jq -r '.identity.principalId') + az spring app identity assign --name ${VETS_SERVICE} + export VETS_SERVICE_IDENTITY=$(az spring app show --name ${VETS_SERVICE} --query 'identity.principalId' --output tsv) - az spring-cloud app identity assign --name ${VISITS_SERVICE} - export VISITS_SERVICE_IDENTITY=$(az spring-cloud app show --name ${VISITS_SERVICE} | jq -r '.identity.principalId') + az spring app identity assign --name --name ${VISITS_SERVICE} + export VISITS_SERVICE_IDENTITY=$(az spring app show --name ${VISITS_SERVICE} --query 'identity.principalId' --output tsv) ``` ### Grant Managed Identities with access to Azure Key Vault @@ -699,32 +719,33 @@ Add an access policy to Azure Key Vault to allow Managed Identities to read secr Activate applications to load secrets from Azure Key Vault. ```bash + KEY_VAULT_URI=$(az keyvault show --name ${KEY_VAULT} --query 'properties.vaultUri' --output tsv) # DO NOT FORGET to replace the value for "azure.keyvault.uri" JVM startup parameter with your Key Vault URI - az spring-cloud app update --name ${CUSTOMERS_SERVICE} \ - --jvm-options='-Xms2048m -Xmx2048m -Dspring.profiles.active=mysql,key-vault -Dazure.keyvault.uri=https://petclinic-keyvault.vault.azure.net/' \ - --env + az spring app update --name ${CUSTOMERS_SERVICE} \ + --jvm-options='-Xms2048m -Xmx2048m' \ + --env SPRING_PROFILES_ACTIVE=mysql,key-vault AZURE_KEYVAULT_URI=${KEY_VAULT_URI} # DO NOT FORGET to replace the value for "azure.keyvault.uri" JVM startup parameter with your Key Vault URI - az spring-cloud app update --name ${VETS_SERVICE} \ - --jvm-options='-Xms2048m -Xmx2048m -Dspring.profiles.active=mysql,key-vault -Dazure.keyvault.uri=https://petclinic-keyvault.vault.azure.net/' \ - --env + az spring app update --name ${VETS_SERVICE} \ + --jvm-options='-Xms2048m -Xmx2048m' \ + --env SPRING_PROFILES_ACTIVE=mysql,key-vault AZURE_KEYVAULT_URI=${KEY_VAULT_URI} # DO NOT FORGET to replace the value for "azure.keyvault.uri" JVM startup parameter with your Key Vault URI - az spring-cloud app update --name ${VISITS_SERVICE} \ - --jvm-options='-Xms2048m -Xmx2048m -Dspring.profiles.active=mysql,key-vault -Dazure.keyvault.uri=https://petclinic-keyvault.vault.azure.net/' \ - --env + az spring app update --name ${VISITS_SERVICE} \ + --jvm-options='-Xms2048m -Xmx2048m' \ + --env SPRING_PROFILES_ACTIVE=mysql,key-vault AZURE_KEYVAULT_URI=${KEY_VAULT_URI} ``` ## Next Steps -In this quickstart, you've deployed an existing Spring Boot-based app using Azure CLI, Terraform and GitHub Actions. To learn more about Azure Spring Cloud, go to: +In this quickstart, you've deployed an existing Spring Boot-based app using Azure CLI, Terraform and GitHub Actions. To learn more about Azure Spring Apps, go to: -- [Azure Spring Cloud](https://azure.microsoft.com/en-us/services/spring-cloud/) -- [Azure Spring Cloud docs](https://docs.microsoft.com/en-us/azure/java/) +- [Azure Spring Apps](https://azure.microsoft.com/products/spring-apps/) +- [Azure Spring Apps docs](https://learn.microsoft.com/azure/developer/java/) - [Deploy Spring microservices from scratch](https://github.com/microsoft/azure-spring-cloud-training) - [Deploy existing Spring microservices](https://github.com/Azure-Samples/azure-spring-cloud) -- [Azure for Java Cloud Developers](https://docs.microsoft.com/en-us/azure/java/) -- [Spring Cloud Azure](https://cloud.spring.io/spring-cloud-azure/) +- [Azure for Java Cloud Developers](https://learn.microsoft.com/azure/developer/java/) +- [Spring Cloud Azure](https://spring.io/projects/spring-cloud-azure) - [Spring Cloud](https://spring.io/projects/spring-cloud) ## Credits