├── .gitignore ├── .mvn └── wrapper │ ├── maven-wrapper.jar │ └── maven-wrapper.properties ├── CPU-hot-spots.csv ├── README.adoc ├── alt └── pom.xml ├── benchmarks ├── loaded.awk ├── logs │ ├── demo.loaded.txt │ └── petclinic.loaded.txt ├── pom.xml └── src │ ├── main │ └── java │ │ └── com │ │ └── example │ │ ├── ConfigServerBenchmark.java │ │ ├── DevToolsLauncherState.java │ │ ├── Java10CdsBenchmark.java │ │ ├── MinimalBenchmark.java │ │ ├── OracleCdsBenchmark.java │ │ ├── PetclinicBenchmark.java │ │ ├── PetclinicLatestBenchmark.java │ │ ├── ProcessLauncherState.java │ │ ├── ShadedBenchmark.java │ │ ├── SpringBoot13xBenchmark.java │ │ ├── SpringBoot14xBenchmark.java │ │ ├── SpringBoot15xBenchmark.java │ │ ├── SpringBoot20xBenchmark.java │ │ └── SpringBootThinBenchmark.java │ └── test │ └── resources │ ├── demo-1.3.8-thin.jar │ └── demo-1.5.3-thin.jar ├── configserver ├── pom.xml └── src │ └── main │ ├── config │ └── application.yml │ ├── java │ └── demo │ │ └── ConfigServerApplication.java │ └── resources │ ├── application.yml │ └── keystore.jks ├── data.adoc ├── demo ├── .gitignore ├── bin │ ├── .gitignore │ ├── .mvn │ │ └── wrapper │ │ │ ├── maven-wrapper.jar │ │ │ └── maven-wrapper.properties │ ├── mvnw │ ├── mvnw.cmd │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── example │ │ │ │ └── DemoApplication.class │ │ └── resources │ │ │ └── application.properties │ │ └── test │ │ └── java │ │ └── com │ │ └── example │ │ └── DemoApplicationTests.class ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── example │ │ │ └── DemoApplication.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── com │ └── example │ └── DemoApplicationTests.java ├── flux ├── README.adoc ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── example │ │ │ ├── boot │ │ │ └── BootApplication.java │ │ │ ├── config │ │ │ ├── ApplicationBuilder.java │ │ │ ├── BeanCountingApplicationListener.java │ │ │ ├── LazyInitBeanFactoryPostProcessor.java │ │ │ ├── ShutdownApplicationListener.java │ │ │ └── StartupApplicationListener.java │ │ │ ├── demo │ │ │ └── DemoApplication.java │ │ │ ├── empt │ │ │ └── EmptyApplication.java │ │ │ ├── micro │ │ │ └── MicroApplication.java │ │ │ └── mini │ │ │ └── MiniApplication.java │ └── resources │ │ ├── application.properties │ │ └── logback.xml │ └── test │ ├── java │ └── com │ │ └── example │ │ ├── bench │ │ ├── MainBenchmark.java │ │ ├── MiniBenchmark.java │ │ ├── ProcessLauncherState.java │ │ ├── ProcessLauncherStateTests.java │ │ └── VirtualMachineMetrics.java │ │ ├── demo │ │ ├── DemoApplicationTests.java │ │ └── StaticApplicationTests.java │ │ └── mini │ │ └── MiniApplicationTests.java │ └── resources │ └── META-INF │ ├── spring.factories │ ├── thin-actj.properties │ ├── thin-actr.properties │ ├── thin-empt.properties │ ├── thin-jdbc.properties │ ├── thin-jlog.properties │ └── thin.properties ├── launcher ├── .gitignore ├── README.adoc ├── pom.xml └── src │ ├── it │ ├── settings.xml │ └── support │ │ ├── pom.xml │ │ └── src │ │ └── main │ │ └── java │ │ └── com │ │ └── example │ │ └── demo │ │ └── DemoApplication.java │ ├── main │ ├── java │ │ └── com │ │ │ └── example │ │ │ ├── CsvResultsFormatter.java │ │ │ ├── CsvResultsWriter.java │ │ │ ├── FileCopyUtils.java │ │ │ ├── LauncherMain.java │ │ │ ├── MainBenchmark.java │ │ │ ├── ProcessLauncherState.java │ │ │ ├── StringUtils.java │ │ │ ├── VirtualMachineMetrics.java │ │ │ └── config │ │ │ ├── BeanCountingApplicationListener.java │ │ │ ├── ShutdownApplicationListener.java │ │ │ └── StartupApplicationListener.java │ └── resources │ │ └── META-INF │ │ └── spring.factories │ └── test │ └── java │ └── com │ └── example │ ├── LauncherMainTests.java │ └── ProcessLauncherStateTests.java ├── minimal ├── .gitignore ├── Dockerfile ├── bin │ ├── .gitignore │ ├── .mvn │ │ └── wrapper │ │ │ ├── maven-wrapper.jar │ │ │ └── maven-wrapper.properties │ ├── mvnw │ ├── mvnw.cmd │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── example │ │ │ │ └── DemoApplication.class │ │ └── resources │ │ │ └── application.properties │ │ └── test │ │ └── java │ │ └── com │ │ └── example │ │ └── DemoApplicationTests.class ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── example │ │ │ └── DemoApplication.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── com │ └── example │ └── DemoApplicationTests.java ├── mvc ├── README.adoc ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── example │ │ │ ├── config │ │ │ ├── BeanCountingApplicationListener.java │ │ │ ├── LazyInitBeanFactoryPostProcessor.java │ │ │ ├── ShutdownApplicationListener.java │ │ │ └── StartupApplicationListener.java │ │ │ ├── demo │ │ │ └── DemoApplication.java │ │ │ └── empt │ │ │ └── EmptyApplication.java │ └── resources │ │ ├── application.properties │ │ └── logback.xml │ └── test │ ├── java │ └── com │ │ └── example │ │ ├── bench │ │ ├── MainBenchmark.java │ │ ├── ProcessLauncherState.java │ │ ├── ProcessLauncherStateTests.java │ │ └── VirtualMachineMetrics.java │ │ └── demo │ │ ├── DemoApplicationTests.java │ │ └── StaticApplicationTests.java │ └── resources │ └── META-INF │ ├── spring.factories │ ├── thin-actj.properties │ ├── thin-actr.properties │ ├── thin-empt.properties │ ├── thin-jdbc.properties │ ├── thin-jlog.properties │ └── thin.properties ├── mvnw ├── mvnw.cmd ├── petclinic-latest ├── .editorconfig ├── .travis.yml ├── Dockerfile ├── pom.xml ├── readme.md ├── sonar-project.properties └── src │ ├── main │ ├── java │ │ └── org │ │ │ └── springframework │ │ │ └── samples │ │ │ └── petclinic │ │ │ ├── PetClinicApplication.java │ │ │ ├── model │ │ │ ├── BaseEntity.java │ │ │ ├── NamedEntity.java │ │ │ ├── Person.java │ │ │ └── package-info.java │ │ │ ├── owner │ │ │ ├── Owner.java │ │ │ ├── OwnerController.java │ │ │ ├── OwnerRepository.java │ │ │ ├── Pet.java │ │ │ ├── PetController.java │ │ │ ├── PetRepository.java │ │ │ ├── PetType.java │ │ │ ├── PetTypeFormatter.java │ │ │ ├── PetValidator.java │ │ │ └── VisitController.java │ │ │ ├── system │ │ │ ├── BeanCountingApplicationListener.java │ │ │ ├── CacheConfig.java │ │ │ ├── CrashController.java │ │ │ ├── LazyInitBeanFactoryPostProcessor.java │ │ │ ├── LazyRepositoryPostProcessor.java │ │ │ └── WelcomeController.java │ │ │ ├── vet │ │ │ ├── Specialty.java │ │ │ ├── Vet.java │ │ │ ├── VetController.java │ │ │ ├── VetRepository.java │ │ │ └── Vets.java │ │ │ └── visit │ │ │ ├── Visit.java │ │ │ └── VisitRepository.java │ ├── less │ │ ├── header.less │ │ ├── petclinic.less │ │ ├── responsive.less │ │ └── typography.less │ ├── resources │ │ ├── META-INF │ │ │ └── spring.factories │ │ ├── application.properties │ │ ├── banner.txt │ │ ├── db │ │ │ ├── hsqldb │ │ │ │ ├── data.sql │ │ │ │ └── schema.sql │ │ │ └── mysql │ │ │ │ ├── data.sql │ │ │ │ ├── petclinic_db_setup_mysql.txt │ │ │ │ └── schema.sql │ │ ├── messages │ │ │ ├── messages.properties │ │ │ ├── messages_de.properties │ │ │ └── messages_en.properties │ │ ├── static │ │ │ └── resources │ │ │ │ ├── fonts │ │ │ │ ├── montserrat-webfont.eot │ │ │ │ ├── montserrat-webfont.svg │ │ │ │ ├── montserrat-webfont.ttf │ │ │ │ ├── montserrat-webfont.woff │ │ │ │ ├── varela_round-webfont.eot │ │ │ │ ├── varela_round-webfont.svg │ │ │ │ ├── varela_round-webfont.ttf │ │ │ │ └── varela_round-webfont.woff │ │ │ │ └── images │ │ │ │ ├── favicon.png │ │ │ │ ├── pets.png │ │ │ │ ├── platform-bg.png │ │ │ │ ├── spring-logo-dataflow-mobile.png │ │ │ │ ├── spring-logo-dataflow.png │ │ │ │ └── spring-pivotal-logo.png │ │ └── templates │ │ │ ├── error.html │ │ │ ├── fragments │ │ │ ├── inputField.html │ │ │ ├── layout.html │ │ │ └── selectField.html │ │ │ ├── owners │ │ │ ├── createOrUpdateOwnerForm.html │ │ │ ├── findOwners.html │ │ │ ├── ownerDetails.html │ │ │ └── ownersList.html │ │ │ ├── pets │ │ │ ├── createOrUpdatePetForm.html │ │ │ └── createOrUpdateVisitForm.html │ │ │ ├── vets │ │ │ └── vetList.html │ │ │ └── welcome.html │ └── wro │ │ ├── wro.properties │ │ └── wro.xml │ └── test │ ├── java │ └── org │ │ └── springframework │ │ └── samples │ │ └── petclinic │ │ ├── model │ │ └── ValidatorTests.java │ │ ├── owner │ │ ├── OwnerControllerTests.java │ │ ├── PetControllerTests.java │ │ ├── PetTypeFormatterTests.java │ │ └── VisitControllerTests.java │ │ ├── service │ │ ├── ClinicServiceTests.java │ │ └── EntityUtils.java │ │ ├── system │ │ └── CrashControllerTests.java │ │ └── vet │ │ └── VetControllerTests.java │ └── jmeter │ └── petclinic_test_plan.jmx ├── petclinic ├── .editorconfig ├── .travis.yml ├── pom.xml ├── readme.md ├── sonar-project.properties └── src │ ├── main │ ├── java │ │ └── org │ │ │ └── springframework │ │ │ └── samples │ │ │ └── petclinic │ │ │ ├── PetClinicApplication.java │ │ │ ├── model │ │ │ ├── BaseEntity.java │ │ │ ├── NamedEntity.java │ │ │ ├── Person.java │ │ │ └── package-info.java │ │ │ ├── owner │ │ │ ├── Owner.java │ │ │ ├── OwnerController.java │ │ │ ├── OwnerRepository.java │ │ │ ├── Pet.java │ │ │ ├── PetController.java │ │ │ ├── PetRepository.java │ │ │ ├── PetType.java │ │ │ ├── PetTypeFormatter.java │ │ │ ├── PetValidator.java │ │ │ └── VisitController.java │ │ │ ├── system │ │ │ ├── CacheConfig.java │ │ │ ├── CrashController.java │ │ │ └── WelcomeController.java │ │ │ ├── vet │ │ │ ├── Specialty.java │ │ │ ├── Vet.java │ │ │ ├── VetController.java │ │ │ ├── VetRepository.java │ │ │ └── Vets.java │ │ │ └── visit │ │ │ ├── Visit.java │ │ │ └── VisitRepository.java │ ├── less │ │ ├── header.less │ │ ├── petclinic.less │ │ ├── responsive.less │ │ └── typography.less │ ├── resources │ │ ├── application.properties │ │ ├── banner.txt │ │ ├── db │ │ │ ├── hsqldb │ │ │ │ ├── data.sql │ │ │ │ └── schema.sql │ │ │ └── mysql │ │ │ │ ├── data.sql │ │ │ │ ├── petclinic_db_setup_mysql.txt │ │ │ │ └── schema.sql │ │ ├── messages │ │ │ ├── messages.properties │ │ │ ├── messages_de.properties │ │ │ └── messages_en.properties │ │ ├── static │ │ │ └── resources │ │ │ │ ├── fonts │ │ │ │ ├── montserrat-webfont.eot │ │ │ │ ├── montserrat-webfont.svg │ │ │ │ ├── montserrat-webfont.ttf │ │ │ │ ├── montserrat-webfont.woff │ │ │ │ ├── varela_round-webfont.eot │ │ │ │ ├── varela_round-webfont.svg │ │ │ │ ├── varela_round-webfont.ttf │ │ │ │ └── varela_round-webfont.woff │ │ │ │ └── images │ │ │ │ ├── favicon.png │ │ │ │ ├── pets.png │ │ │ │ ├── platform-bg.png │ │ │ │ ├── spring-logo-dataflow-mobile.png │ │ │ │ ├── spring-logo-dataflow.png │ │ │ │ └── spring-pivotal-logo.png │ │ └── templates │ │ │ ├── error.html │ │ │ ├── fragments │ │ │ ├── inputField.html │ │ │ ├── layout.html │ │ │ └── selectField.html │ │ │ ├── owners │ │ │ ├── createOrUpdateOwnerForm.html │ │ │ ├── findOwners.html │ │ │ ├── ownerDetails.html │ │ │ └── ownersList.html │ │ │ ├── pets │ │ │ ├── createOrUpdatePetForm.html │ │ │ └── createOrUpdateVisitForm.html │ │ │ ├── vets │ │ │ └── vetList.html │ │ │ └── welcome.html │ └── wro │ │ ├── wro.properties │ │ └── wro.xml │ └── test │ ├── java │ └── org │ │ └── springframework │ │ └── samples │ │ └── petclinic │ │ ├── model │ │ └── ValidatorTests.java │ │ ├── owner │ │ ├── OwnerControllerTests.java │ │ ├── PetControllerTests.java │ │ ├── PetTypeFormatterTests.java │ │ └── VisitControllerTests.java │ │ ├── service │ │ ├── ClinicServiceTests.java │ │ └── EntityUtils.java │ │ ├── system │ │ └── CrashControllerTests.java │ │ └── vet │ │ └── VetControllerTests.java │ └── jmeter │ └── petclinic_test_plan.jmx ├── pom.xml ├── s1p.txt ├── startup.adoc ├── static ├── README.adoc ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── example │ │ │ ├── config │ │ │ ├── ApplicationBuilder.java │ │ │ ├── BeanCountingApplicationListener.java │ │ │ ├── ShutdownApplicationListener.java │ │ │ └── StartupApplicationListener.java │ │ │ ├── demo │ │ │ └── DemoApplication.java │ │ │ ├── func │ │ │ └── FuncApplication.java │ │ │ ├── jpa │ │ │ └── JpaApplication.java │ │ │ ├── lite │ │ │ └── LiteApplication.java │ │ │ ├── slim │ │ │ └── SlimApplication.java │ │ │ └── thin │ │ │ └── ThinApplication.java │ └── resources │ │ ├── META-INF │ │ └── spring.factories │ │ ├── application.properties │ │ └── logback.xml │ └── test │ ├── java │ └── com │ │ └── example │ │ ├── bench │ │ ├── CaptureSystemOutput.java │ │ ├── CdsBenchmark.java │ │ ├── CsvResultsWriterFactory.java │ │ ├── DevToolsBenchmark.java │ │ ├── DevToolsLauncherState.java │ │ ├── MainBenchmark.java │ │ ├── ProcessLauncherState.java │ │ ├── ProcessLauncherStateTests.java │ │ ├── StripBenchmark.java │ │ └── VirtualMachineMetrics.java │ │ ├── demo │ │ ├── CustomConfiguration.java │ │ ├── DemoApplicationTests.java │ │ └── StaticApplicationTests.java │ │ ├── func │ │ └── FuncApplicationTests.java │ │ ├── lite │ │ └── LiteApplicationTests.java │ │ └── thin │ │ └── ThinApplicationTests.java │ └── resources │ └── META-INF │ ├── services │ └── jmh.mbr.core.ResultsWriterFactory │ ├── thin-actj.properties │ ├── thin-actr.properties │ ├── thin-buna.properties │ ├── thin-busr.properties │ ├── thin-conf.properties │ ├── thin-devtools.properties │ ├── thin-empt.properties │ ├── thin-erka.properties │ ├── thin-erkb.properties │ ├── thin-flux.properties │ ├── thin-jdbc.properties │ ├── thin-jlog.properties │ ├── thin-jpae.properties │ ├── thin-slth.properties │ ├── thin-zuul.properties │ └── thin.properties ├── vagrant └── Vagrantfile └── yourkit.adoc /.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | dependency-reduced-pom.xml 4 | interpolated-pom.xml 5 | .#* 6 | *# 7 | *~ 8 | build.log 9 | .attach_* 10 | _site/ 11 | 12 | ### STS ### 13 | .apt_generated 14 | .classpath 15 | .factorypath 16 | .project 17 | .settings 18 | .springBeans 19 | 20 | ### IntelliJ IDEA ### 21 | .idea 22 | *.iws 23 | *.iml 24 | *.ipr 25 | 26 | ### NetBeans ### 27 | nbproject/private/ 28 | build/ 29 | nbbuild/ 30 | dist/ 31 | nbdist/ 32 | .nb-gradle/ 33 | 34 | ### VSCode ### 35 | .vscode 36 | .sts4-cache/ 37 | -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dsyer/spring-boot-startup-bench/c68adbcb4ab70005d8a056c34ea42e0b1f7ab810/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.3.9/apache-maven-3.3.9-bin.zip 2 | -------------------------------------------------------------------------------- /benchmarks/loaded.awk: -------------------------------------------------------------------------------- 1 | BEGIN { 2 | cls = 0 3 | } 4 | /.* --- \[/ { 5 | if (cls>0) { 6 | print "Loaded " cls " classes" 7 | } 8 | print $0 9 | cls = 0 10 | } 11 | /\[Loaded/ { 12 | cls = cls + 1 13 | } 14 | -------------------------------------------------------------------------------- /benchmarks/src/main/java/com/example/DevToolsLauncherState.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */package com.example; 16 | 17 | import java.io.File; 18 | import java.io.IOException; 19 | import java.nio.file.Files; 20 | import java.nio.file.Path; 21 | import java.util.Date; 22 | import java.util.stream.Collectors; 23 | import java.util.stream.IntStream; 24 | 25 | public class DevToolsLauncherState extends ProcessLauncherState { 26 | 27 | private Path restart; 28 | private int count = 0; 29 | 30 | public DevToolsLauncherState(String dir, String restart, String jar, String... args) { 31 | super(dir, args); 32 | this.restart = new File(dir, restart).toPath(); 33 | unpack(dir, jar); 34 | } 35 | 36 | public void setup() throws Exception { 37 | super.run(); 38 | } 39 | 40 | @Override 41 | public void run() throws Exception { 42 | update(); 43 | monitor(); 44 | } 45 | 46 | protected void update() throws IOException { 47 | Files.write(restart, (new Date().toString() + IntStream.range(0, count++) 48 | .mapToObj(i -> "" + i).collect(Collectors.joining(","))).getBytes()); 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /benchmarks/src/main/java/com/example/ShadedBenchmark.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.example; 18 | 19 | import org.openjdk.jmh.annotations.Benchmark; 20 | import org.openjdk.jmh.annotations.BenchmarkMode; 21 | import org.openjdk.jmh.annotations.Fork; 22 | import org.openjdk.jmh.annotations.Level; 23 | import org.openjdk.jmh.annotations.Measurement; 24 | import org.openjdk.jmh.annotations.Mode; 25 | import org.openjdk.jmh.annotations.Scope; 26 | import org.openjdk.jmh.annotations.State; 27 | import org.openjdk.jmh.annotations.TearDown; 28 | import org.openjdk.jmh.annotations.Warmup; 29 | 30 | @Measurement(iterations = 5) 31 | @Warmup(iterations = 1) 32 | @Fork(value = 2, warmups = 0) 33 | @BenchmarkMode(Mode.AverageTime) 34 | public class ShadedBenchmark { 35 | 36 | @Benchmark 37 | public void shaded(ShadedState state) throws Exception { 38 | state.run(); 39 | } 40 | 41 | @Benchmark 42 | public void explodedShadedMain(ShadedMainState state) throws Exception { 43 | state.run(); 44 | } 45 | 46 | @State(Scope.Benchmark) 47 | public static class ShadedState extends ProcessLauncherState { 48 | public ShadedState() { 49 | super("target", "-jar", jarFile("com.example:petclinic:jar:shade:1.4.2"), 50 | "--server.port=0"); 51 | } 52 | 53 | @TearDown(Level.Iteration) 54 | public void stop() throws Exception { 55 | super.after(); 56 | } 57 | } 58 | 59 | @State(Scope.Benchmark) 60 | public static class ShadedMainState extends ProcessLauncherState { 61 | public ShadedMainState() { 62 | super("target/demo", "-cp", ".", 63 | "org.springframework.samples.petclinic.PetClinicApplication", 64 | "--server.port=0"); 65 | unpack("target/demo", jarFile("com.example:petclinic:jar:shade:1.4.2")); 66 | } 67 | 68 | @TearDown(Level.Iteration) 69 | public void stop() throws Exception { 70 | super.after(); 71 | } 72 | } 73 | 74 | } 75 | -------------------------------------------------------------------------------- /benchmarks/src/test/resources/demo-1.3.8-thin.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dsyer/spring-boot-startup-bench/c68adbcb4ab70005d8a056c34ea42e0b1f7ab810/benchmarks/src/test/resources/demo-1.3.8-thin.jar -------------------------------------------------------------------------------- /benchmarks/src/test/resources/demo-1.5.3-thin.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dsyer/spring-boot-startup-bench/c68adbcb4ab70005d8a056c34ea42e0b1f7ab810/benchmarks/src/test/resources/demo-1.5.3-thin.jar -------------------------------------------------------------------------------- /configserver/src/main/config/application.yml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dsyer/spring-boot-startup-bench/c68adbcb4ab70005d8a056c34ea42e0b1f7ab810/configserver/src/main/config/application.yml -------------------------------------------------------------------------------- /configserver/src/main/java/demo/ConfigServerApplication.java: -------------------------------------------------------------------------------- 1 | package demo; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.config.server.EnableConfigServer; 6 | 7 | @SpringBootApplication 8 | @EnableConfigServer 9 | public class ConfigServerApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(ConfigServerApplication.class, args); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /configserver/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8888 3 | spring: 4 | application: 5 | name: configserver 6 | cloud: 7 | config: 8 | server: 9 | git: 10 | uri: https://github.com/spring-cloud-samples/config-repo 11 | encrypt: 12 | enabled: false 13 | 14 | --- 15 | spring: 16 | profiles: encrypt 17 | cloud: 18 | config: 19 | server: 20 | overrides: 21 | info.bar: '\{cipher}762c11829d517b203ac94a0180f1950b133b83cde34296549d8fed611a9b2fb5' 22 | 23 | encrypt: 24 | key: ${SECRET_KEY:foo} # normally this would be an environment variable 25 | 26 | --- 27 | spring: 28 | profiles: rsa 29 | cloud: 30 | config: 31 | server: 32 | overrides: 33 | info.bar: '\{cipher}AQAj4tMJizMZS9sBvGjqRz4e6hxKpYXBA3CdtNMBeqS8UaLc8uiy4iydcD8C9z3cDMVprUYXjonCYarwU+13ggtxBUXuNAR1HAzCKWgkB+h8oAtYhBFb3+6gAFb4dFV+9h+DUID6OpAWmFfXj0QI0cuOMx7CXecLSflFAOtF1YUz2y9eQLp2bF8aDx8R/0TEYAYWjLGfibxOXRxRVKH3qLO4YQwQTmnHn5jtIVHtzsmo2ywJq4ySpuRZysy5gxWJwv4ogzVhk46gSesjhfX5Ysbwz6ZP4dQmzGWt8dNrzI99wBUzUXppNv5xtO/E8tUtD6TVJ/CpZuXvmuV5gpZ1Ni2w+ZDBpQfDjs74rqUdUWhnYc6KEj8hM2FaBUESqu7yweQ=' 34 | 35 | encrypt: 36 | failOnError: false 37 | keyStore: 38 | location: classpath:keystore.jks 39 | password: ${KEYSTORE_PASSWORD:foobar} # don't use a default in production 40 | alias: test 41 | 42 | -------------------------------------------------------------------------------- /configserver/src/main/resources/keystore.jks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dsyer/spring-boot-startup-bench/c68adbcb4ab70005d8a056c34ea42e0b1f7ab810/configserver/src/main/resources/keystore.jks -------------------------------------------------------------------------------- /data.adoc: -------------------------------------------------------------------------------- 1 | # Changes to Spring Data Commons 2 | 3 | Some observations were made from TRACE logging in the 4 | petclinic. Instead of component scanning we could use 5 | `spring.factories` for detecting "plugin" behaviour in Spring Data 6 | Commons. These https://jira.spring.io/browse/DATACMNS-952[changes] 7 | were made and the petclinic re-tested. 8 | 9 | Before: 10 | 11 | ``` 12 | PetclinicBenchmark.devtoolsRestart avgt 10 1.387 ± 0.399 s/op 13 | PetclinicBenchmark.explodedJarMain avgt 10 5.491 ± 0.357 s/op 14 | PetclinicBenchmark.fatJar avgt 10 6.130 ± 0.271 s/op 15 | PetclinicBenchmark.noverify avgt 10 5.430 ± 0.217 s/op 16 | ``` 17 | 18 | After: 19 | 20 | ``` 21 | Benchmark Mode Cnt Score Error Units 22 | PetclinicBenchmark.devtoolsRestart avgt 10 1.261 ± 0.188 s/op 23 | PetclinicBenchmark.explodedJarMain avgt 10 5.088 ± 0.207 s/op 24 | PetclinicBenchmark.fatJar avgt 10 5.860 ± 0.244 s/op 25 | PetclinicBenchmark.noverify avgt 10 5.318 ± 0.180 s/op 26 | ``` 27 | 28 | The changes are in `RepositoryConfigurationDelegate` and 29 | `SpringDataWebConfigurationImportSelector` (where the component scan 30 | is used in each case). The difference is perceptible, but doesn't 31 | deliver the hoped for 800ms improvement. It is now available using 32 | `spring-data-releasetrain.version=Ingalls-BUILD-SNAPSHOT`. -------------------------------------------------------------------------------- /demo/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | 12 | ### IntelliJ IDEA ### 13 | .idea 14 | *.iws 15 | *.iml 16 | *.ipr 17 | 18 | ### NetBeans ### 19 | nbproject/private/ 20 | build/ 21 | nbbuild/ 22 | dist/ 23 | nbdist/ 24 | .nb-gradle/ -------------------------------------------------------------------------------- /demo/bin/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | 12 | ### IntelliJ IDEA ### 13 | .idea 14 | *.iws 15 | *.iml 16 | *.ipr 17 | 18 | ### NetBeans ### 19 | nbproject/private/ 20 | build/ 21 | nbbuild/ 22 | dist/ 23 | nbdist/ 24 | .nb-gradle/ -------------------------------------------------------------------------------- /demo/bin/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dsyer/spring-boot-startup-bench/c68adbcb4ab70005d8a056c34ea42e0b1f7ab810/demo/bin/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /demo/bin/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.3.9/apache-maven-3.3.9-bin.zip 2 | -------------------------------------------------------------------------------- /demo/bin/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.example 7 | demo 8 | 0.0.1-SNAPSHOT 9 | jar 10 | 11 | demo 12 | Demo project for Spring Boot 13 | 14 | 15 | org.springframework.boot 16 | spring-boot-starter-parent 17 | 1.4.2.RELEASE 18 | 19 | 20 | 21 | 22 | UTF-8 23 | UTF-8 24 | 1.8 25 | 26 | 27 | 28 | 29 | org.springframework.boot 30 | spring-boot-starter-actuator 31 | 32 | 33 | org.springframework.cloud 34 | spring-cloud-starter-config 35 | 36 | 37 | org.springframework.boot 38 | spring-boot-starter-web 39 | 40 | 41 | 42 | org.springframework.boot 43 | spring-boot-starter-test 44 | test 45 | 46 | 47 | 48 | 49 | 50 | 51 | org.springframework.cloud 52 | spring-cloud-dependencies 53 | Camden.SR2 54 | pom 55 | import 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | org.springframework.boot 64 | spring-boot-maven-plugin 65 | 66 | 67 | 68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /demo/bin/src/main/java/com/example/DemoApplication.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dsyer/spring-boot-startup-bench/c68adbcb4ab70005d8a056c34ea42e0b1f7ab810/demo/bin/src/main/java/com/example/DemoApplication.class -------------------------------------------------------------------------------- /demo/bin/src/main/resources/application.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dsyer/spring-boot-startup-bench/c68adbcb4ab70005d8a056c34ea42e0b1f7ab810/demo/bin/src/main/resources/application.properties -------------------------------------------------------------------------------- /demo/bin/src/test/java/com/example/DemoApplicationTests.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dsyer/spring-boot-startup-bench/c68adbcb4ab70005d8a056c34ea42e0b1f7ab810/demo/bin/src/test/java/com/example/DemoApplicationTests.class -------------------------------------------------------------------------------- /demo/src/main/java/com/example/DemoApplication.java: -------------------------------------------------------------------------------- 1 | package com.example; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class DemoApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(DemoApplication.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /demo/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | server.port=8000 2 | # logging.level.org.apache.catalina=TRACE 3 | # logging.level.org.apache.tomcat=TRACE 4 | #logging.level.org.springframework.context.annotation=DEBUG 5 | #logging.level.org.springframework=TRACE -------------------------------------------------------------------------------- /demo/src/test/java/com/example/DemoApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.example; 2 | 3 | public class DemoApplicationTests { 4 | } 5 | -------------------------------------------------------------------------------- /flux/src/main/java/com/example/config/LazyInitBeanFactoryPostProcessor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.example.config; 17 | 18 | import org.springframework.beans.BeansException; 19 | import org.springframework.beans.factory.config.BeanDefinition; 20 | import org.springframework.beans.factory.config.BeanFactoryPostProcessor; 21 | import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; 22 | import org.springframework.stereotype.Component; 23 | 24 | @Component 25 | public class LazyInitBeanFactoryPostProcessor implements BeanFactoryPostProcessor { 26 | 27 | private Class[] exclusionList; 28 | 29 | public LazyInitBeanFactoryPostProcessor() { 30 | } 31 | 32 | public LazyInitBeanFactoryPostProcessor(Class[] exclusionList) { 33 | this.exclusionList = exclusionList; 34 | } 35 | 36 | @Override 37 | public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) 38 | throws BeansException { 39 | 40 | // Iterate over all bean, mark them as lazy if they are not in the exclusion list. 41 | for (String beanName : beanFactory.getBeanDefinitionNames()) { 42 | if (isLazy(beanName, beanFactory)) { 43 | BeanDefinition definition = beanFactory.getBeanDefinition(beanName); 44 | definition.setLazyInit(true); 45 | } 46 | } 47 | } 48 | 49 | private boolean isLazy(String beanName, ConfigurableListableBeanFactory beanFactory) { 50 | if (exclusionList == null || exclusionList.length == 0) { 51 | return true; 52 | } 53 | for (Class clazz : exclusionList) { 54 | if (beanFactory.isTypeMatch(beanName, clazz)) { 55 | return false; 56 | } 57 | } 58 | return true; 59 | } 60 | } -------------------------------------------------------------------------------- /flux/src/main/java/com/example/demo/DemoApplication.java: -------------------------------------------------------------------------------- 1 | package com.example.demo; 2 | 3 | import org.springframework.boot.autoconfigure.SpringBootApplication; 4 | import org.springframework.boot.builder.SpringApplicationBuilder; 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | import org.springframework.web.bind.annotation.RestController; 7 | 8 | @SpringBootApplication(proxyBeanMethods = false) 9 | @RestController 10 | public class DemoApplication { 11 | 12 | @GetMapping("/") 13 | public String home() { 14 | return "Hello"; 15 | } 16 | 17 | public static void main(String[] args) throws Exception { 18 | new SpringApplicationBuilder(DemoApplication.class).run(args); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /flux/src/main/java/com/example/empt/EmptyApplication.java: -------------------------------------------------------------------------------- 1 | package com.example.empt; 2 | 3 | import org.springframework.boot.autoconfigure.SpringBootApplication; 4 | import org.springframework.boot.builder.SpringApplicationBuilder; 5 | 6 | @SpringBootApplication 7 | // @Import(LazyInitBeanFactoryPostProcessor.class) 8 | public class EmptyApplication { 9 | 10 | public static void main(String[] args) throws Exception { 11 | new SpringApplicationBuilder(EmptyApplication.class).run(args); 12 | Thread thread = new Thread() { 13 | @Override 14 | public void run() { 15 | while (true) { 16 | try { 17 | Thread.sleep(100L); 18 | } 19 | catch (InterruptedException e) { 20 | Thread.currentThread().interrupt(); 21 | } 22 | } 23 | } 24 | }; 25 | thread.setDaemon(false); 26 | thread.start(); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /flux/src/main/java/com/example/micro/MicroApplication.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.example.micro; 17 | 18 | import com.example.config.ApplicationBuilder; 19 | 20 | import org.springframework.context.support.GenericApplicationContext; 21 | import org.springframework.web.reactive.function.server.RouterFunction; 22 | import org.springframework.web.reactive.function.server.RouterFunctions; 23 | import org.springframework.web.server.WebHandler; 24 | 25 | import static org.springframework.web.reactive.function.server.RequestPredicates.GET; 26 | import static org.springframework.web.reactive.function.server.ServerResponse.ok; 27 | 28 | import reactor.core.publisher.Mono; 29 | 30 | /** 31 | * @author Dave Syer 32 | * 33 | */ 34 | public class MicroApplication { 35 | 36 | public static void main(String[] args) throws Exception { 37 | GenericApplicationContext context = new GenericApplicationContext(); 38 | context.registerBean(RouterFunction.class, () -> RouterFunctions.route(GET("/"), 39 | request -> ok().body(Mono.just("Hello"), String.class))); 40 | context.registerBean("webHandler", WebHandler.class, () -> RouterFunctions 41 | .toWebHandler(context.getBean(RouterFunction.class))); 42 | context.refresh(); 43 | ApplicationBuilder.start(context); 44 | } 45 | } -------------------------------------------------------------------------------- /flux/src/main/java/com/example/mini/MiniApplication.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.example.mini; 17 | 18 | import com.example.config.ApplicationBuilder; 19 | 20 | import reactor.core.publisher.Mono; 21 | 22 | import org.springframework.boot.SpringBootConfiguration; 23 | import org.springframework.context.annotation.AnnotationConfigApplicationContext; 24 | import org.springframework.context.annotation.Bean; 25 | import org.springframework.web.reactive.config.EnableWebFlux; 26 | import org.springframework.web.reactive.function.server.RouterFunction; 27 | 28 | import static org.springframework.web.reactive.function.server.RequestPredicates.GET; 29 | import static org.springframework.web.reactive.function.server.RouterFunctions.route; 30 | import static org.springframework.web.reactive.function.server.ServerResponse.ok; 31 | 32 | /** 33 | * @author Dave Syer 34 | * 35 | */ 36 | @SpringBootConfiguration 37 | @EnableWebFlux 38 | // @Import(LazyInitBeanFactoryPostProcessor.class) 39 | public class MiniApplication { 40 | 41 | public static void main(String[] args) throws Exception { 42 | AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); 43 | context.register(MiniApplication.class); 44 | context.refresh(); 45 | ApplicationBuilder.start(context); 46 | } 47 | 48 | @Bean 49 | public RouterFunction userEndpoints() { 50 | return route(GET("/"), request -> ok().body(Mono.just("Hello"), String.class)); 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /flux/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | # logging.level.org.springframework=DEBUG 2 | # logging.level.com.example=DEBUG 3 | # logging.level.org.springframework.beans.factory.support=DEBUG 4 | #management.security.enabled=false -------------------------------------------------------------------------------- /flux/src/main/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /flux/src/test/java/com/example/bench/ProcessLauncherStateTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.example.bench; 18 | 19 | import com.example.demo.DemoApplication; 20 | import org.junit.jupiter.api.Test; 21 | import org.junit.jupiter.api.extension.ExtendWith; 22 | 23 | import org.springframework.boot.test.system.CapturedOutput; 24 | import org.springframework.boot.test.system.OutputCaptureExtension; 25 | 26 | import static org.assertj.core.api.Assertions.assertThat; 27 | 28 | /** 29 | * @author Dave Syer 30 | * 31 | */ 32 | @ExtendWith(OutputCaptureExtension.class) 33 | public class ProcessLauncherStateTests { 34 | 35 | @Test 36 | public void vanilla(CapturedOutput output) throws Exception { 37 | // System.setProperty("bench.args", "-verbose:class"); 38 | ProcessLauncherState state = new ProcessLauncherState("target", 39 | "--server.port=0"); 40 | state.setMainClass(DemoApplication.class.getName()); 41 | state.setProfiles("jlog"); 42 | state.before(); 43 | state.run(); 44 | state.after(); 45 | assertThat(output.toString()).contains("Benchmark app started"); 46 | assertThat(state.getHeap()).isGreaterThan(0); 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /flux/src/test/java/com/example/demo/DemoApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.example.demo; 2 | 3 | import org.junit.jupiter.api.Test; 4 | 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.annotation.DirtiesContext; 7 | 8 | @SpringBootTest 9 | @DirtiesContext 10 | public class DemoApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() throws Exception { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /flux/src/test/java/com/example/mini/MiniApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.example.mini; 2 | 3 | import org.junit.jupiter.api.Test; 4 | 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.annotation.DirtiesContext; 7 | 8 | @SpringBootTest(properties = "server.port=0") 9 | @DirtiesContext 10 | public class MiniApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() throws Exception { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /flux/src/test/resources/META-INF/spring.factories: -------------------------------------------------------------------------------- 1 | org.springframework.context.ApplicationListener=\ 2 | com.example.config.BeanCountingApplicationListener,\ 3 | com.example.config.StartupApplicationListener,\ 4 | com.example.config.ShutdownApplicationListener 5 | -------------------------------------------------------------------------------- /flux/src/test/resources/META-INF/thin-actj.properties: -------------------------------------------------------------------------------- 1 | dependencies.spring-boot-starter-actuator=org.springframework.boot:spring-boot-starter-actuator 2 | dependencies.spring-boot-starter-web=org.springframework.boot:spring-boot-starter-webflux 3 | dependencies.spring-boot-starter-jdbc=org.springframework.boot:spring-boot-starter-jdbc 4 | dependencies.h2=com.h2database:h2 5 | -------------------------------------------------------------------------------- /flux/src/test/resources/META-INF/thin-actr.properties: -------------------------------------------------------------------------------- 1 | dependencies.spring-boot-starter-web=org.springframework.boot:spring-boot-starter-webflux 2 | dependencies.spring-boot-starter-actuator=org.springframework.boot:spring-boot-starter-actuator 3 | -------------------------------------------------------------------------------- /flux/src/test/resources/META-INF/thin-empt.properties: -------------------------------------------------------------------------------- 1 | exclusions.spring-boot-starter-webflux=org.springframework.boot:spring-boot-starter-webflux 2 | dependencies.spring-boot-starter-web=org.springframework.boot:spring-boot-starter 3 | -------------------------------------------------------------------------------- /flux/src/test/resources/META-INF/thin-jdbc.properties: -------------------------------------------------------------------------------- 1 | dependencies.spring-boot-starter-web=org.springframework.boot:spring-boot-starter-webflux 2 | dependencies.spring-boot-starter-jdbc=org.springframework.boot:spring-boot-starter-jdbc 3 | dependencies.h2=com.h2database:h2 4 | -------------------------------------------------------------------------------- /flux/src/test/resources/META-INF/thin-jlog.properties: -------------------------------------------------------------------------------- 1 | exclusions.spring-boot-starter-logging=org.springframework.boot:spring-boot-starter-logging 2 | exclusions.spring-boot-starter-json=org.springframework.boot:spring-boot-starter-json 3 | exclusions.jackson-databind=com.fasterxml.jackson.core:jackson-databind 4 | exclusions.hibernate-validator=org.hibernate.validator:hibernate-validator 5 | exclusions.jakarta-validator=jakarta.validation:jakarta.validation-api 6 | exclusions.old-hibernate-validator=org.hibernate:hibernate-validator 7 | dependencies.slf4j-jdk14=org.slf4j:slf4j-jdk14 -------------------------------------------------------------------------------- /flux/src/test/resources/META-INF/thin.properties: -------------------------------------------------------------------------------- 1 | # spring-boot.version=2.0.0.RELEASE 2 | exclusions.microbench=com.github.mp911de.microbenchmark-runner:microbenchmark-runner-junit5 3 | exclusions.jmh-core=org.openjdk.jmh:jmh-core 4 | exclusions.spring-boot-thin-launcher=org.springframework.boot.experimental:spring-boot-thin-launcher 5 | exclusions.log4j-to-slf4j=org.apache.logging.log4j:log4j-to-slf4j 6 | # Comment out proxyBeanMethods=false if you use this: 7 | #boms.spring-boot-dependencies=org.springframework.boot:spring-boot-dependencies:2.1.9.RELEASE 8 | #boms.spring-boot-dependencies=org.springframework.boot:spring-boot-dependencies:2.0.9.RELEASE -------------------------------------------------------------------------------- /launcher/.gitignore: -------------------------------------------------------------------------------- 1 | logs/ 2 | benchmark.properties 3 | -------------------------------------------------------------------------------- /launcher/README.adoc: -------------------------------------------------------------------------------- 1 | This module provides a general purpose benchmark for any Spring Boot jar. You pass it the jar file to measure on the command line. It works for fat and thin jars, created with the Spring Boot tooling. 2 | 3 | Example usage: 4 | 5 | ``` 6 | $ java -jar target/benchmarks.jar ~/dev/spring/spring-petclinic/target/spring-petclinic-2.1.0.jar 7 | ... 8 | # Run complete. Total time: 00:02:44 9 | 10 | ... 11 | 12 | class, method, beans, classes, heap, memory, median, mean, range 13 | com.example.MainBenchmark, jar, ≈ 0, 10775.000, 31.530, 125.987, 5.192, 5.289, 0.129 14 | com.example.MainBenchmark, launcher, 367.000, 10799.000, 36.254, 130.941, 3.881, 4.025, 0.170 15 | com.example.MainBenchmark, main, 365.000, 10752.000, 36.751, 130.943, 3.587, 3.679, 0.095 16 | ``` 17 | 18 | NOTE: If you are seeing "≈ 0" values for all the JVM metrics you probably don't have a `tools.jar` on your classpath. You need to either use a full JDK, or supplement the boot classpath, e.g. add `-Xbootclasspath/a:/tools.jar` to the command line. 19 | 20 | For the "jar" benchmark the app has to emit a log containing "started on port" (by default) when it is ready. You can change the "marker" that the benchmark looks for with --marker='Foo Bar' (for instance). Multiple values are acceptable, and any will terminate the measurement. 21 | 22 | For the "main" (exploded jar with main class) and "launcher" (exploded jar with Boot launcher) benchmarks it also installs a listener that prints the number of classes loaded and the number of beans. 23 | 24 | To measure the time to first request, add `-Drequest.uri=http://localhost:8080` (or whatever) and `--server.port=8080` (by default the port will be set to 0). To add JVM command line options for the launched application processes, use `-Dbench.args`. 25 | 26 | To pass arguments to JMH you need to put them after a single argument of `--`. E.g. 27 | 28 | ``` 29 | $ java -jar target/benchmarks.jar target/it/support/target/demo-1.0.0-exec.jar -- MainBenchmark.launcher 30 | ``` -------------------------------------------------------------------------------- /launcher/src/it/settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | it-repo 6 | 7 | true 8 | 9 | 10 | 11 | local.central 12 | @localRepositoryUrl@ 13 | 14 | true 15 | 16 | 17 | true 18 | 19 | 20 | 21 | 22 | 23 | local.central 24 | @localRepositoryUrl@ 25 | 26 | true 27 | 28 | 29 | true 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /launcher/src/it/support/src/main/java/com/example/demo/DemoApplication.java: -------------------------------------------------------------------------------- 1 | package com.example.demo; 2 | 3 | import org.springframework.boot.autoconfigure.SpringBootApplication; 4 | import org.springframework.boot.builder.SpringApplicationBuilder; 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | import org.springframework.web.bind.annotation.RestController; 7 | 8 | @SpringBootApplication 9 | @RestController 10 | public class DemoApplication { 11 | 12 | @GetMapping("/") 13 | public String home() { 14 | return "Hello"; 15 | } 16 | 17 | public static void main(String[] args) throws Exception { 18 | new SpringApplicationBuilder(DemoApplication.class).run(args); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /launcher/src/main/java/com/example/CsvResultsWriter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 the original author or authors. 3 | * 4 | * All rights reserved. This program and the accompanying materials are 5 | * made available under the terms of the Eclipse Public License v2.0 which 6 | * accompanies this distribution and is available at 7 | * 8 | * http://www.eclipse.org/legal/epl-v20.html 9 | */ 10 | package com.example; 11 | 12 | import java.io.PrintWriter; 13 | import java.io.StringWriter; 14 | import java.util.Collection; 15 | 16 | import org.openjdk.jmh.results.RunResult; 17 | import org.openjdk.jmh.runner.format.OutputFormat; 18 | 19 | class CsvResultsWriter { 20 | 21 | public void write(OutputFormat output, Collection results) { 22 | 23 | try { 24 | String report = CsvResultsFormatter.createReport(results); 25 | 26 | output.println(report); 27 | } 28 | catch (Exception e) { 29 | 30 | StringWriter trace = new StringWriter(); 31 | e.printStackTrace(new PrintWriter(trace)); 32 | 33 | output.println("Report creation failed: " + trace.toString()); 34 | } 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /launcher/src/main/java/com/example/StringUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.example; 17 | 18 | /** 19 | * @author Dave Syer 20 | * 21 | */ 22 | public class StringUtils { 23 | 24 | public static String[] commaDelimitedListToStringArray(String property) { 25 | return property.split(","); 26 | } 27 | 28 | public static String arrayToCommaDelimitedString(String[] globals) { 29 | return String.join(",", globals); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /launcher/src/main/resources/META-INF/spring.factories: -------------------------------------------------------------------------------- 1 | org.springframework.context.ApplicationListener=\ 2 | com.example.config.BeanCountingApplicationListener,\ 3 | com.example.config.StartupApplicationListener,\ 4 | com.example.config.ShutdownApplicationListener 5 | -------------------------------------------------------------------------------- /launcher/src/test/java/com/example/LauncherMainTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.example; 17 | 18 | import com.example.LauncherMain.Args; 19 | 20 | import org.junit.Test; 21 | 22 | import static org.assertj.core.api.Assertions.assertThat; 23 | 24 | /** 25 | * @author Dave Syer 26 | * 27 | */ 28 | public class LauncherMainTests { 29 | 30 | @Test 31 | public void justJar() { 32 | Args args = new Args(new String[] { "my.jar" }); 33 | assertThat(args.getProgArgs()[0]).isEqualTo("my.jar"); 34 | assertThat(args.getJmhArgs()).isEmpty(); 35 | } 36 | 37 | @Test 38 | public void jarPlusJmh() { 39 | Args args = new Args(new String[] { "my.jar", "--", "-i", "1" }); 40 | assertThat(args.getProgArgs()[0]).isEqualTo("my.jar"); 41 | assertThat(args.getJmhArgs()).contains("-i"); 42 | assertThat(args.getJmhArgs()).hasSize(2); 43 | } 44 | 45 | @Test 46 | public void jarPlusArgsPlusJmh() { 47 | Args args = new Args( 48 | new String[] { "my.jar", "--server.port=0", "--", "-i", "1" }); 49 | assertThat(args.getProgArgs()[0]).isEqualTo("my.jar"); 50 | assertThat(args.getProgArgs()).hasSize(2); 51 | assertThat(args.getJmhArgs()).contains("-i"); 52 | assertThat(args.getJmhArgs()).hasSize(2); 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /minimal/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | 12 | ### IntelliJ IDEA ### 13 | .idea 14 | *.iws 15 | *.iml 16 | *.ipr 17 | 18 | ### NetBeans ### 19 | nbproject/private/ 20 | build/ 21 | nbbuild/ 22 | dist/ 23 | nbdist/ 24 | .nb-gradle/ -------------------------------------------------------------------------------- /minimal/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM frolvlad/alpine-oraclejdk8:slim 2 | VOLUME /tmp 3 | ADD target/minimal-0.0.1-SNAPSHOT.jar app.jar 4 | RUN sh -c 'touch /app.jar' 5 | ENV JAVA_OPTS="" 6 | ENTRYPOINT [ "sh", "-c", "java $JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -jar /app.jar" ] 7 | -------------------------------------------------------------------------------- /minimal/bin/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | 12 | ### IntelliJ IDEA ### 13 | .idea 14 | *.iws 15 | *.iml 16 | *.ipr 17 | 18 | ### NetBeans ### 19 | nbproject/private/ 20 | build/ 21 | nbbuild/ 22 | dist/ 23 | nbdist/ 24 | .nb-gradle/ -------------------------------------------------------------------------------- /minimal/bin/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dsyer/spring-boot-startup-bench/c68adbcb4ab70005d8a056c34ea42e0b1f7ab810/minimal/bin/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /minimal/bin/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.3.9/apache-maven-3.3.9-bin.zip 2 | -------------------------------------------------------------------------------- /minimal/bin/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.example 7 | demo 8 | 0.0.1-SNAPSHOT 9 | jar 10 | 11 | demo 12 | Demo project for Spring Boot 13 | 14 | 15 | org.springframework.boot 16 | spring-boot-starter-parent 17 | 1.4.2.RELEASE 18 | 19 | 20 | 21 | 22 | UTF-8 23 | UTF-8 24 | 1.8 25 | 26 | 27 | 28 | 29 | org.springframework.boot 30 | spring-boot-starter-actuator 31 | 32 | 33 | org.springframework.cloud 34 | spring-cloud-starter-config 35 | 36 | 37 | org.springframework.boot 38 | spring-boot-starter-web 39 | 40 | 41 | 42 | org.springframework.boot 43 | spring-boot-starter-test 44 | test 45 | 46 | 47 | 48 | 49 | 50 | 51 | org.springframework.cloud 52 | spring-cloud-dependencies 53 | Camden.SR2 54 | pom 55 | import 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | org.springframework.boot 64 | spring-boot-maven-plugin 65 | 66 | 67 | 68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /minimal/bin/src/main/java/com/example/DemoApplication.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dsyer/spring-boot-startup-bench/c68adbcb4ab70005d8a056c34ea42e0b1f7ab810/minimal/bin/src/main/java/com/example/DemoApplication.class -------------------------------------------------------------------------------- /minimal/bin/src/main/resources/application.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dsyer/spring-boot-startup-bench/c68adbcb4ab70005d8a056c34ea42e0b1f7ab810/minimal/bin/src/main/resources/application.properties -------------------------------------------------------------------------------- /minimal/bin/src/test/java/com/example/DemoApplicationTests.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dsyer/spring-boot-startup-bench/c68adbcb4ab70005d8a056c34ea42e0b1f7ab810/minimal/bin/src/test/java/com/example/DemoApplicationTests.class -------------------------------------------------------------------------------- /minimal/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | server.port=8000 2 | # logging.level.org.apache.catalina=TRACE 3 | # logging.level.org.apache.tomcat=TRACE 4 | #logging.level.org.springframework.context.annotation=DEBUG 5 | #logging.level.org.springframework=TRACE -------------------------------------------------------------------------------- /minimal/src/test/java/com/example/DemoApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.example; 2 | 3 | public class DemoApplicationTests { 4 | } 5 | -------------------------------------------------------------------------------- /mvc/src/main/java/com/example/config/LazyInitBeanFactoryPostProcessor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.example.config; 17 | 18 | import org.springframework.beans.BeansException; 19 | import org.springframework.beans.factory.config.BeanDefinition; 20 | import org.springframework.beans.factory.config.BeanFactoryPostProcessor; 21 | import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; 22 | import org.springframework.stereotype.Component; 23 | 24 | @Component 25 | public class LazyInitBeanFactoryPostProcessor implements BeanFactoryPostProcessor { 26 | 27 | private Class[] exclusionList; 28 | 29 | public LazyInitBeanFactoryPostProcessor() { 30 | } 31 | 32 | public LazyInitBeanFactoryPostProcessor(Class[] exclusionList) { 33 | this.exclusionList = exclusionList; 34 | } 35 | 36 | @Override 37 | public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) 38 | throws BeansException { 39 | 40 | // Iterate over all bean, mark them as lazy if they are not in the exclusion list. 41 | for (String beanName : beanFactory.getBeanDefinitionNames()) { 42 | if (isLazy(beanName, beanFactory)) { 43 | BeanDefinition definition = beanFactory.getBeanDefinition(beanName); 44 | definition.setLazyInit(true); 45 | } 46 | } 47 | } 48 | 49 | private boolean isLazy(String beanName, ConfigurableListableBeanFactory beanFactory) { 50 | if (exclusionList == null || exclusionList.length == 0) { 51 | return true; 52 | } 53 | for (Class clazz : exclusionList) { 54 | if (beanFactory.isTypeMatch(beanName, clazz)) { 55 | return false; 56 | } 57 | } 58 | return true; 59 | } 60 | } -------------------------------------------------------------------------------- /mvc/src/main/java/com/example/demo/DemoApplication.java: -------------------------------------------------------------------------------- 1 | package com.example.demo; 2 | 3 | import org.springframework.boot.autoconfigure.SpringBootApplication; 4 | import org.springframework.boot.builder.SpringApplicationBuilder; 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | import org.springframework.web.bind.annotation.RestController; 7 | 8 | @SpringBootApplication(proxyBeanMethods = false) 9 | @RestController 10 | public class DemoApplication { 11 | 12 | @GetMapping("/") 13 | public String home() { 14 | return "Hello"; 15 | } 16 | 17 | public static void main(String[] args) throws Exception { 18 | new SpringApplicationBuilder(DemoApplication.class).run(args); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /mvc/src/main/java/com/example/empt/EmptyApplication.java: -------------------------------------------------------------------------------- 1 | package com.example.empt; 2 | 3 | import org.springframework.boot.autoconfigure.SpringBootApplication; 4 | import org.springframework.boot.builder.SpringApplicationBuilder; 5 | 6 | @SpringBootApplication 7 | // @Import(LazyInitBeanFactoryPostProcessor.class) 8 | public class EmptyApplication { 9 | 10 | public static void main(String[] args) throws Exception { 11 | new SpringApplicationBuilder(EmptyApplication.class).run(args); 12 | Thread thread = new Thread() { 13 | @Override 14 | public void run() { 15 | while (true) { 16 | try { 17 | Thread.sleep(100L); 18 | } 19 | catch (InterruptedException e) { 20 | Thread.currentThread().interrupt(); 21 | } 22 | } 23 | } 24 | }; 25 | thread.setDaemon(false); 26 | thread.start(); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /mvc/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | # logging.level.org.springframework=DEBUG 2 | # logging.level.com.example=DEBUG 3 | # logging.level.org.springframework.beans.factory.support=DEBUG 4 | #management.security.enabled=false -------------------------------------------------------------------------------- /mvc/src/main/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /mvc/src/test/java/com/example/bench/ProcessLauncherStateTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.example.bench; 18 | 19 | import com.example.demo.DemoApplication; 20 | import org.junit.jupiter.api.Test; 21 | import org.junit.jupiter.api.extension.ExtendWith; 22 | 23 | import org.springframework.boot.test.system.CapturedOutput; 24 | import org.springframework.boot.test.system.OutputCaptureExtension; 25 | 26 | import static org.assertj.core.api.Assertions.assertThat; 27 | 28 | /** 29 | * @author Dave Syer 30 | * 31 | */ 32 | @ExtendWith(OutputCaptureExtension.class) 33 | public class ProcessLauncherStateTests { 34 | 35 | @Test 36 | public void vanilla(CapturedOutput output) throws Exception { 37 | // System.setProperty("bench.args", "-verbose:class"); 38 | ProcessLauncherState state = new ProcessLauncherState("target", 39 | "--server.port=0"); 40 | state.setMainClass(DemoApplication.class.getName()); 41 | // state.setProfiles("jlog"); 42 | state.before(); 43 | state.run(); 44 | state.after(); 45 | assertThat(output.toString()).contains("Benchmark app started"); 46 | assertThat(state.getHeap()).isGreaterThan(0); 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /mvc/src/test/java/com/example/demo/DemoApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.example.demo; 2 | 3 | import org.junit.jupiter.api.Test; 4 | 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.annotation.DirtiesContext; 7 | 8 | @SpringBootTest 9 | @DirtiesContext 10 | public class DemoApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() throws Exception { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /mvc/src/test/resources/META-INF/spring.factories: -------------------------------------------------------------------------------- 1 | org.springframework.context.ApplicationListener=\ 2 | com.example.config.BeanCountingApplicationListener,\ 3 | com.example.config.StartupApplicationListener,\ 4 | com.example.config.ShutdownApplicationListener 5 | -------------------------------------------------------------------------------- /mvc/src/test/resources/META-INF/thin-actj.properties: -------------------------------------------------------------------------------- 1 | dependencies.spring-boot-starter-actuator=org.springframework.boot:spring-boot-starter-actuator 2 | dependencies.spring-boot-starter-jdbc=org.springframework.boot:spring-boot-starter-jdbc 3 | dependencies.h2=com.h2database:h2 4 | -------------------------------------------------------------------------------- /mvc/src/test/resources/META-INF/thin-actr.properties: -------------------------------------------------------------------------------- 1 | dependencies.spring-boot-starter-actuator=org.springframework.boot:spring-boot-starter-actuator 2 | -------------------------------------------------------------------------------- /mvc/src/test/resources/META-INF/thin-empt.properties: -------------------------------------------------------------------------------- 1 | exclusions.spring-boot-starter-webflux=org.springframework.boot:spring-boot-starter-web 2 | dependencies.spring-boot-starter-web=org.springframework.boot:spring-boot-starter 3 | -------------------------------------------------------------------------------- /mvc/src/test/resources/META-INF/thin-jdbc.properties: -------------------------------------------------------------------------------- 1 | dependencies.spring-boot-starter-jdbc=org.springframework.boot:spring-boot-starter-jdbc 2 | dependencies.h2=com.h2database:h2 3 | -------------------------------------------------------------------------------- /mvc/src/test/resources/META-INF/thin-jlog.properties: -------------------------------------------------------------------------------- 1 | exclusions.spring-boot-starter-logging=org.springframework.boot:spring-boot-starter-logging 2 | exclusions.spring-boot-starter-json=org.springframework.boot:spring-boot-starter-json 3 | exclusions.jackson-databind=com.fasterxml.jackson.core:jackson-databind 4 | exclusions.hibernate-validator=org.hibernate.validator:hibernate-validator 5 | exclusions.jakarta-validator=jakarta.validation:jakarta.validation-api 6 | exclusions.old-hibernate-validator=org.hibernate:hibernate-validator 7 | dependencies.slf4j-jdk14=org.slf4j:slf4j-jdk14 -------------------------------------------------------------------------------- /mvc/src/test/resources/META-INF/thin.properties: -------------------------------------------------------------------------------- 1 | # spring-boot.version=2.0.0.RELEASE 2 | exclusions.microbench=com.github.mp911de.microbenchmark-runner:microbenchmark-runner-junit5 3 | exclusions.jmh-core=org.openjdk.jmh:jmh-core 4 | exclusions.spring-boot-thin-launcher=org.springframework.boot.experimental:spring-boot-thin-launcher 5 | exclusions.log4j-to-slf4j=org.apache.logging.log4j:log4j-to-slf4j 6 | # Comment out proxyBeanMethods=false if you use this: 7 | #boms.spring-boot-dependencies=org.springframework.boot:spring-boot-dependencies:2.1.9.RELEASE 8 | #boms.spring-boot-dependencies=org.springframework.boot:spring-boot-dependencies:2.0.9.RELEASE -------------------------------------------------------------------------------- /petclinic-latest/.editorconfig: -------------------------------------------------------------------------------- 1 | # top-most EditorConfig file 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | end_of_line = lf 7 | insert_final_newline = true 8 | indent_style = space 9 | 10 | [*.{java,xml}] 11 | indent_size = 4 12 | trim_trailing_whitespace = true 13 | -------------------------------------------------------------------------------- /petclinic-latest/.travis.yml: -------------------------------------------------------------------------------- 1 | language: java 2 | jdk: oraclejdk8 3 | -------------------------------------------------------------------------------- /petclinic-latest/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM openjdk:8-jdk-alpine 2 | VOLUME /tmp 3 | ARG JAR_FILE 4 | COPY ${JAR_FILE} app.jar 5 | ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"] 6 | -------------------------------------------------------------------------------- /petclinic-latest/sonar-project.properties: -------------------------------------------------------------------------------- 1 | # Required metadata 2 | sonar.projectKey=java-sonar-runner-simple 3 | sonar.projectName=Simple Java project analyzed with the SonarQube Runner 4 | sonar.projectVersion=1.0 5 | 6 | # Comma-separated paths to directories with sources (required) 7 | sonar.sources=src 8 | 9 | # Language 10 | sonar.language=java 11 | 12 | # Encoding of the source files 13 | sonar.sourceEncoding=UTF-8 -------------------------------------------------------------------------------- /petclinic-latest/src/main/java/org/springframework/samples/petclinic/PetClinicApplication.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2014 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.samples.petclinic; 18 | 19 | import org.springframework.boot.SpringApplication; 20 | import org.springframework.boot.autoconfigure.SpringBootApplication; 21 | 22 | /** 23 | * PetClinic Spring Boot Application. 24 | * 25 | * @author Dave Syer 26 | * 27 | */ 28 | @SpringBootApplication 29 | // @Import({ LazyInitBeanFactoryPostProcessor.class, LazyRepositoryPostProcessor.class }) 30 | public class PetClinicApplication { 31 | 32 | public static void main(String[] args) throws Exception { 33 | SpringApplication.run(PetClinicApplication.class, args); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /petclinic-latest/src/main/java/org/springframework/samples/petclinic/model/BaseEntity.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2013 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.samples.petclinic.model; 17 | 18 | import javax.persistence.GeneratedValue; 19 | import javax.persistence.GenerationType; 20 | import javax.persistence.Id; 21 | import javax.persistence.MappedSuperclass; 22 | 23 | /** 24 | * Simple JavaBean domain object with an id property. Used as a base class for objects needing this property. 25 | * 26 | * @author Ken Krebs 27 | * @author Juergen Hoeller 28 | */ 29 | @MappedSuperclass 30 | public class BaseEntity { 31 | @Id 32 | @GeneratedValue(strategy = GenerationType.IDENTITY) 33 | protected Integer id; 34 | 35 | public Integer getId() { 36 | return id; 37 | } 38 | 39 | public void setId(Integer id) { 40 | this.id = id; 41 | } 42 | 43 | public boolean isNew() { 44 | return this.id == null; 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /petclinic-latest/src/main/java/org/springframework/samples/petclinic/model/NamedEntity.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2013 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.samples.petclinic.model; 17 | 18 | import javax.persistence.Column; 19 | import javax.persistence.MappedSuperclass; 20 | 21 | 22 | /** 23 | * Simple JavaBean domain object adds a name property to BaseEntity. Used as a base class for objects 24 | * needing these properties. 25 | * 26 | * @author Ken Krebs 27 | * @author Juergen Hoeller 28 | */ 29 | @MappedSuperclass 30 | public class NamedEntity extends BaseEntity { 31 | 32 | @Column(name = "name") 33 | private String name; 34 | 35 | public String getName() { 36 | return this.name; 37 | } 38 | 39 | public void setName(String name) { 40 | this.name = name; 41 | } 42 | 43 | @Override 44 | public String toString() { 45 | return this.getName(); 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /petclinic-latest/src/main/java/org/springframework/samples/petclinic/model/Person.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2013 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.samples.petclinic.model; 17 | 18 | import javax.persistence.Column; 19 | import javax.persistence.MappedSuperclass; 20 | 21 | import org.hibernate.validator.constraints.NotEmpty; 22 | 23 | /** 24 | * Simple JavaBean domain object representing an person. 25 | * 26 | * @author Ken Krebs 27 | */ 28 | @MappedSuperclass 29 | public class Person extends BaseEntity { 30 | 31 | @Column(name = "first_name") 32 | @NotEmpty 33 | protected String firstName; 34 | 35 | @Column(name = "last_name") 36 | @NotEmpty 37 | protected String lastName; 38 | 39 | public String getFirstName() { 40 | return this.firstName; 41 | } 42 | 43 | public void setFirstName(String firstName) { 44 | this.firstName = firstName; 45 | } 46 | 47 | public String getLastName() { 48 | return this.lastName; 49 | } 50 | 51 | public void setLastName(String lastName) { 52 | this.lastName = lastName; 53 | } 54 | 55 | 56 | } 57 | -------------------------------------------------------------------------------- /petclinic-latest/src/main/java/org/springframework/samples/petclinic/model/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * The classes in this package represent utilities used by the domain. 3 | */ 4 | package org.springframework.samples.petclinic.model; 5 | 6 | -------------------------------------------------------------------------------- /petclinic-latest/src/main/java/org/springframework/samples/petclinic/owner/PetRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2013 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.samples.petclinic.owner; 17 | 18 | import java.util.List; 19 | 20 | import org.springframework.data.jpa.repository.Query; 21 | import org.springframework.data.repository.Repository; 22 | import org.springframework.transaction.annotation.Transactional; 23 | 24 | /** 25 | * Repository class for Pet domain objects All method names are compliant with Spring Data naming 26 | * conventions so this interface can easily be extended for Spring Data See here: http://static.springsource.org/spring-data/jpa/docs/current/reference/html/jpa.repositories.html#jpa.query-methods.query-creation 27 | * 28 | * @author Ken Krebs 29 | * @author Juergen Hoeller 30 | * @author Sam Brannen 31 | * @author Michael Isvy 32 | */ 33 | public interface PetRepository extends Repository { 34 | 35 | /** 36 | * Retrieve all {@link PetType}s from the data store. 37 | * @return a Collection of {@link PetType}s. 38 | */ 39 | @Query("SELECT ptype FROM PetType ptype ORDER BY ptype.name") 40 | @Transactional(readOnly = true) 41 | List findPetTypes(); 42 | 43 | /** 44 | * Retrieve a {@link Pet} from the data store by id. 45 | * @param id the id to search for 46 | * @return the {@link Pet} if found 47 | */ 48 | @Transactional(readOnly = true) 49 | Pet findById(Integer id); 50 | 51 | /** 52 | * Save a {@link Pet} to the data store, either inserting or updating it. 53 | * @param pet the {@link Pet} to save 54 | */ 55 | void save(Pet pet); 56 | 57 | } 58 | 59 | -------------------------------------------------------------------------------- /petclinic-latest/src/main/java/org/springframework/samples/petclinic/owner/PetType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2013 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.samples.petclinic.owner; 17 | 18 | import javax.persistence.Entity; 19 | import javax.persistence.Table; 20 | 21 | import org.springframework.samples.petclinic.model.NamedEntity; 22 | 23 | /** 24 | * @author Juergen Hoeller 25 | * Can be Cat, Dog, Hamster... 26 | */ 27 | @Entity 28 | @Table(name = "types") 29 | public class PetType extends NamedEntity { 30 | 31 | } 32 | -------------------------------------------------------------------------------- /petclinic-latest/src/main/java/org/springframework/samples/petclinic/owner/PetValidator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2013 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.samples.petclinic.owner; 17 | 18 | import org.springframework.util.StringUtils; 19 | import org.springframework.validation.Errors; 20 | import org.springframework.validation.Validator; 21 | 22 | /** 23 | * Validator for Pet forms. 24 | *

25 | * We're not using Bean Validation annotations here because it is easier to define such validation rule in Java. 26 | *

27 | * 28 | * @author Ken Krebs 29 | * @author Juergen Hoeller 30 | */ 31 | public class PetValidator implements Validator { 32 | 33 | private static final String REQUIRED = "required"; 34 | 35 | @Override 36 | public void validate(Object obj, Errors errors) { 37 | Pet pet = (Pet) obj; 38 | String name = pet.getName(); 39 | // name validation 40 | if (!StringUtils.hasLength(name)) { 41 | errors.rejectValue("name", REQUIRED, REQUIRED); 42 | } 43 | 44 | // type validation 45 | if (pet.isNew() && pet.getType() == null) { 46 | errors.rejectValue("type", REQUIRED, REQUIRED); 47 | } 48 | 49 | // birth date validation 50 | if (pet.getBirthDate() == null) { 51 | errors.rejectValue("birthDate", REQUIRED, REQUIRED); 52 | } 53 | } 54 | 55 | /** 56 | * This Validator validates *just* Pet instances 57 | */ 58 | @Override 59 | public boolean supports(Class clazz) { 60 | return Pet.class.isAssignableFrom(clazz); 61 | } 62 | 63 | 64 | } 65 | -------------------------------------------------------------------------------- /petclinic-latest/src/main/java/org/springframework/samples/petclinic/system/CacheConfig.java: -------------------------------------------------------------------------------- 1 | package org.springframework.samples.petclinic.system; 2 | 3 | import org.springframework.cache.annotation.EnableCaching; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.context.annotation.Profile; 6 | 7 | /** 8 | * Cache could be disable in unit test. 9 | */ 10 | @Configuration 11 | @EnableCaching 12 | @Profile("production") 13 | class CacheConfig { 14 | } 15 | -------------------------------------------------------------------------------- /petclinic-latest/src/main/java/org/springframework/samples/petclinic/system/CrashController.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2013 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.samples.petclinic.system; 17 | 18 | import org.springframework.stereotype.Controller; 19 | import org.springframework.web.bind.annotation.RequestMapping; 20 | import org.springframework.web.bind.annotation.RequestMethod; 21 | 22 | /** 23 | * Controller used to showcase what happens when an exception is thrown 24 | * 25 | * @author Michael Isvy 26 | *

27 | * Also see how a view that resolves to "error" has been added ("error.html"). 28 | */ 29 | @Controller 30 | class CrashController { 31 | 32 | @RequestMapping(value = "/oups", method = RequestMethod.GET) 33 | public String triggerException() { 34 | throw new RuntimeException( 35 | "Expected: controller used to showcase what " + "happens when an exception is thrown"); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /petclinic-latest/src/main/java/org/springframework/samples/petclinic/system/LazyInitBeanFactoryPostProcessor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.samples.petclinic.system; 17 | 18 | import org.springframework.beans.BeansException; 19 | import org.springframework.beans.factory.config.BeanDefinition; 20 | import org.springframework.beans.factory.config.BeanFactoryPostProcessor; 21 | import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; 22 | 23 | // @Component 24 | public class LazyInitBeanFactoryPostProcessor implements BeanFactoryPostProcessor { 25 | 26 | private Class[] exclusionList; 27 | 28 | public LazyInitBeanFactoryPostProcessor() { 29 | } 30 | 31 | public LazyInitBeanFactoryPostProcessor(Class[] exclusionList) { 32 | this.exclusionList = exclusionList; 33 | } 34 | 35 | @Override 36 | public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { 37 | 38 | // Iterate over all bean, mark them as lazy if they are not in the exclusion list. 39 | for (String beanName : beanFactory.getBeanDefinitionNames()) { 40 | if (isLazy(beanName, beanFactory)) { 41 | BeanDefinition definition = beanFactory.getBeanDefinition(beanName); 42 | definition.setLazyInit(true); 43 | } 44 | } 45 | } 46 | 47 | private boolean isLazy(String beanName, ConfigurableListableBeanFactory beanFactory) { 48 | if (exclusionList == null || exclusionList.length == 0) { 49 | return true; 50 | } 51 | for (Class clazz : exclusionList) { 52 | if (beanFactory.isTypeMatch(beanName, clazz)) { 53 | return false; 54 | } 55 | } 56 | return true; 57 | } 58 | } -------------------------------------------------------------------------------- /petclinic-latest/src/main/java/org/springframework/samples/petclinic/system/LazyRepositoryPostProcessor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.samples.petclinic.system; 17 | 18 | import org.springframework.beans.BeansException; 19 | import org.springframework.beans.factory.config.BeanPostProcessor; 20 | import org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport; 21 | 22 | // @Component 23 | public class LazyRepositoryPostProcessor implements BeanPostProcessor { 24 | 25 | @Override 26 | public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException { 27 | if (bean instanceof RepositoryFactoryBeanSupport) { 28 | RepositoryFactoryBeanSupport support = (RepositoryFactoryBeanSupport) bean; 29 | support.setLazyInit(true); 30 | } 31 | return bean; 32 | } 33 | } -------------------------------------------------------------------------------- /petclinic-latest/src/main/java/org/springframework/samples/petclinic/system/WelcomeController.java: -------------------------------------------------------------------------------- 1 | package org.springframework.samples.petclinic.system; 2 | 3 | 4 | import org.springframework.stereotype.Controller; 5 | import org.springframework.web.bind.annotation.RequestMapping; 6 | 7 | @Controller 8 | class WelcomeController { 9 | 10 | @RequestMapping("/") 11 | public String welcome() { 12 | return "welcome"; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /petclinic-latest/src/main/java/org/springframework/samples/petclinic/vet/Specialty.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2013 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.samples.petclinic.vet; 17 | 18 | import javax.persistence.Entity; 19 | import javax.persistence.Table; 20 | 21 | import org.springframework.samples.petclinic.model.NamedEntity; 22 | 23 | /** 24 | * Models a {@link Vet Vet's} specialty (for example, dentistry). 25 | * 26 | * @author Juergen Hoeller 27 | */ 28 | @Entity 29 | @Table(name = "specialties") 30 | public class Specialty extends NamedEntity { 31 | 32 | } 33 | -------------------------------------------------------------------------------- /petclinic-latest/src/main/java/org/springframework/samples/petclinic/vet/VetController.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2013 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.samples.petclinic.vet; 17 | 18 | import java.util.Map; 19 | 20 | import org.springframework.beans.factory.annotation.Autowired; 21 | import org.springframework.context.annotation.Lazy; 22 | import org.springframework.stereotype.Controller; 23 | import org.springframework.web.bind.annotation.RequestMapping; 24 | import org.springframework.web.bind.annotation.ResponseBody; 25 | 26 | /** 27 | * @author Juergen Hoeller 28 | * @author Mark Fisher 29 | * @author Ken Krebs 30 | * @author Arjen Poutsma 31 | */ 32 | @Controller 33 | class VetController { 34 | 35 | private final VetRepository vets; 36 | 37 | @Autowired 38 | public VetController(@Lazy VetRepository clinicService) { 39 | this.vets = clinicService; 40 | } 41 | 42 | @RequestMapping(value = { "/vets.html" }) 43 | public String showVetList(Map model) { 44 | // Here we are returning an object of type 'Vets' rather than a collection of Vet 45 | // objects so it is simpler for Object-Xml mapping 46 | Vets vets = new Vets(); 47 | vets.getVetList().addAll(this.vets.findAll()); 48 | model.put("vets", vets); 49 | return "vets/vetList"; 50 | } 51 | 52 | @RequestMapping(value = { "/vets.json", "/vets.xml" }) 53 | public @ResponseBody Vets showResourcesVetList() { 54 | // Here we are returning an object of type 'Vets' rather than a collection of Vet 55 | // objects so it is simpler for JSon/Object mapping 56 | Vets vets = new Vets(); 57 | vets.getVetList().addAll(this.vets.findAll()); 58 | return vets; 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /petclinic-latest/src/main/java/org/springframework/samples/petclinic/vet/VetRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2013 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.samples.petclinic.vet; 17 | 18 | import java.util.Collection; 19 | 20 | import org.springframework.cache.annotation.Cacheable; 21 | import org.springframework.dao.DataAccessException; 22 | import org.springframework.data.repository.Repository; 23 | import org.springframework.transaction.annotation.Transactional; 24 | 25 | /** 26 | * Repository class for Vet domain objects All method names are compliant with Spring Data naming 27 | * conventions so this interface can easily be extended for Spring Data See here: http://static.springsource.org/spring-data/jpa/docs/current/reference/html/jpa.repositories.html#jpa.query-methods.query-creation 28 | * 29 | * @author Ken Krebs 30 | * @author Juergen Hoeller 31 | * @author Sam Brannen 32 | * @author Michael Isvy 33 | */ 34 | public interface VetRepository extends Repository { 35 | 36 | /** 37 | * Retrieve all Vets from the data store. 38 | * 39 | * @return a Collection of Vets 40 | */ 41 | @Transactional(readOnly = true) 42 | @Cacheable("vets") 43 | Collection findAll() throws DataAccessException; 44 | 45 | 46 | } 47 | -------------------------------------------------------------------------------- /petclinic-latest/src/main/java/org/springframework/samples/petclinic/vet/Vets.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2013 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.samples.petclinic.vet; 17 | 18 | import java.util.ArrayList; 19 | import java.util.List; 20 | 21 | import javax.xml.bind.annotation.XmlElement; 22 | import javax.xml.bind.annotation.XmlRootElement; 23 | 24 | /** 25 | * Simple domain object representing a list of veterinarians. Mostly here to be used for the 'vets' {@link 26 | * org.springframework.web.servlet.view.xml.MarshallingView}. 27 | * 28 | * @author Arjen Poutsma 29 | */ 30 | @XmlRootElement 31 | public class Vets { 32 | 33 | private List vets; 34 | 35 | @XmlElement 36 | public List getVetList() { 37 | if (vets == null) { 38 | vets = new ArrayList<>(); 39 | } 40 | return vets; 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /petclinic-latest/src/main/java/org/springframework/samples/petclinic/visit/VisitRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2013 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.samples.petclinic.visit; 17 | 18 | import java.util.List; 19 | 20 | import org.springframework.dao.DataAccessException; 21 | import org.springframework.data.repository.Repository; 22 | import org.springframework.samples.petclinic.model.BaseEntity; 23 | 24 | /** 25 | * Repository class for Visit domain objects All method names are compliant with Spring Data naming 26 | * conventions so this interface can easily be extended for Spring Data See here: http://static.springsource.org/spring-data/jpa/docs/current/reference/html/jpa.repositories.html#jpa.query-methods.query-creation 27 | * 28 | * @author Ken Krebs 29 | * @author Juergen Hoeller 30 | * @author Sam Brannen 31 | * @author Michael Isvy 32 | */ 33 | public interface VisitRepository extends Repository { 34 | 35 | /** 36 | * Save a Visit to the data store, either inserting or updating it. 37 | * 38 | * @param visit the Visit to save 39 | * @see BaseEntity#isNew 40 | */ 41 | void save(Visit visit) throws DataAccessException; 42 | 43 | List findByPetId(Integer petId); 44 | 45 | } 46 | -------------------------------------------------------------------------------- /petclinic-latest/src/main/less/header.less: -------------------------------------------------------------------------------- 1 | .navbar { 2 | border-top: 4px solid #6db33f; 3 | background-color: #34302d; 4 | margin-bottom: 0px; 5 | border-bottom: 0; 6 | border-left: 0; 7 | border-right: 0; 8 | } 9 | 10 | .navbar a.navbar-brand { 11 | background: url("../images/spring-logo-dataflow.png") -1px -1px no-repeat; 12 | margin: 12px 0 6px; 13 | width: 229px; 14 | height: 46px; 15 | display: inline-block; 16 | text-decoration: none; 17 | padding: 0; 18 | } 19 | 20 | .navbar a.navbar-brand span { 21 | display: block; 22 | width: 229px; 23 | height: 46px; 24 | background: url("../images/spring-logo-dataflow.png") -1px -48px no-repeat; 25 | opacity: 0; 26 | -moz-transition: opacity 0.12s ease-in-out; 27 | -webkit-transition: opacity 0.12s ease-in-out; 28 | -o-transition: opacity 0.12s ease-in-out; 29 | } 30 | 31 | .navbar a:hover.navbar-brand span { 32 | opacity: 1; 33 | } 34 | 35 | .navbar li > a, .navbar-text { 36 | font-family: "montserratregular", sans-serif; 37 | text-shadow: none; 38 | font-size: 14px; 39 | 40 | /* line-height: 14px; */ 41 | padding: 28px 20px; 42 | transition: all 0.15s; 43 | -webkit-transition: all 0.15s; 44 | -moz-transition: all 0.15s; 45 | -o-transition: all 0.15s; 46 | -ms-transition: all 0.15s; 47 | } 48 | 49 | .navbar li > a { 50 | text-transform: uppercase; 51 | } 52 | 53 | .navbar .navbar-text { 54 | margin-top: 0; 55 | margin-bottom: 0; 56 | } 57 | .navbar li:hover > a { 58 | color: #eeeeee; 59 | background-color: #6db33f; 60 | } 61 | 62 | .navbar-toggle { 63 | border-width: 0; 64 | 65 | .icon-bar + .icon-bar { 66 | margin-top: 3px; 67 | } 68 | .icon-bar { 69 | width: 19px; 70 | height: 3px; 71 | } 72 | 73 | } 74 | -------------------------------------------------------------------------------- /petclinic-latest/src/main/less/responsive.less: -------------------------------------------------------------------------------- 1 | @media (max-width: 768px) { 2 | .navbar-toggle { 3 | position:absolute; 4 | z-index: 9999; 5 | left:0px; 6 | top:0px; 7 | } 8 | 9 | .navbar a.navbar-brand { 10 | display: block; 11 | margin: 0 auto 0 auto; 12 | width: 148px; 13 | height: 50px; 14 | float: none; 15 | background: url("../images/spring-logo-dataflow-mobile.png") 0 center no-repeat; 16 | } 17 | 18 | .homepage-billboard .homepage-subtitle { 19 | font-size: 21px; 20 | line-height: 21px; 21 | } 22 | 23 | .navbar a.navbar-brand span { 24 | display: none; 25 | } 26 | 27 | .navbar { 28 | border-top-width: 0; 29 | } 30 | 31 | .xd-container { 32 | margin-top: 20px; 33 | margin-bottom: 30px; 34 | } 35 | 36 | .index-page--subtitle { 37 | margin-top: 10px; 38 | margin-bottom: 30px; 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /petclinic-latest/src/main/less/typography.less: -------------------------------------------------------------------------------- 1 | @font-face { 2 | font-family: 'varela_roundregular'; 3 | 4 | src: url('../fonts/varela_round-webfont.eot'); 5 | src: url('../fonts/varela_round-webfont.eot?#iefix') format('embedded-opentype'), 6 | url('../fonts/varela_round-webfont.woff') format('woff'), 7 | url('../fonts/varela_round-webfont.ttf') format('truetype'), 8 | url('../fonts/varela_round-webfont.svg#varela_roundregular') format('svg'); 9 | font-weight: normal; 10 | font-style: normal; 11 | } 12 | 13 | @font-face { 14 | font-family: 'montserratregular'; 15 | src: url('../fonts/montserrat-webfont.eot'); 16 | src: url('../fonts/montserrat-webfont.eot?#iefix') format('embedded-opentype'), 17 | url('../fonts/montserrat-webfont.woff') format('woff'), 18 | url('../fonts/montserrat-webfont.ttf') format('truetype'), 19 | url('../fonts/montserrat-webfont.svg#montserratregular') format('svg'); 20 | font-weight: normal; 21 | font-style: normal; 22 | } 23 | 24 | body, h1, h2, h3, p, input { 25 | margin: 0; 26 | font-weight: 400; 27 | font-family: "varela_roundregular", sans-serif; 28 | color: #34302d; 29 | } 30 | 31 | h1 { 32 | font-size: 24px; 33 | line-height: 30px; 34 | font-family: "montserratregular", sans-serif; 35 | } 36 | 37 | h2 { 38 | font-size: 18px; 39 | font-weight: 700; 40 | line-height: 24px; 41 | margin-bottom: 10px; 42 | font-family: "montserratregular", sans-serif; 43 | } 44 | 45 | h3 { 46 | font-size: 16px; 47 | line-height: 24px; 48 | margin-bottom: 10px; 49 | font-weight: 700; 50 | } 51 | 52 | p { 53 | //font-size: 15px; 54 | //line-height: 24px; 55 | } 56 | 57 | strong { 58 | font-weight: 700; 59 | font-family: "montserratregular", sans-serif; 60 | } 61 | -------------------------------------------------------------------------------- /petclinic-latest/src/main/resources/META-INF/spring.factories: -------------------------------------------------------------------------------- 1 | org.springframework.context.ApplicationListener=\ 2 | org.springframework.samples.petclinic.system.BeanCountingApplicationListener 3 | -------------------------------------------------------------------------------- /petclinic-latest/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | # database init, supports mysql too 2 | database=hsqldb 3 | spring.datasource.schema=classpath*:db/${database}/schema.sql 4 | spring.datasource.data=classpath*:db/${database}/data.sql 5 | 6 | # Web 7 | spring.thymeleaf.mode=HTML 8 | 9 | # JPA 10 | spring.jpa.hibernate.ddl-auto=none 11 | 12 | # Internationalization 13 | spring.messages.basename=messages/messages 14 | 15 | # Actuator / Management 16 | management.endpoints.web.base-path=/manage 17 | # Spring Boot 1.5 makes actuator secure by default 18 | management.endpoints.web.exposure.include=* 19 | 20 | # Logging 21 | # logging.level.org.springframework.context.annotation=TRACE 22 | 23 | # Active Spring profiles 24 | spring.profiles.active=production 25 | spring.cache.cache-names=vets -------------------------------------------------------------------------------- /petclinic-latest/src/main/resources/banner.txt: -------------------------------------------------------------------------------- 1 | 2 | 3 | |\ _,,,--,,_ 4 | /,`.-'`' ._ \-;;,_ 5 | _______ __|,4- ) )_ .;.(__`'-'__ ___ __ _ ___ _______ 6 | | | '---''(_/._)-'(_\_) | | | | | | | | | 7 | | _ | ___|_ _| | | | | |_| | | | __ _ _ 8 | | |_| | |___ | | | | | | | | | | \ \ \ \ 9 | | ___| ___| | | | _| |___| | _ | | _| \ \ \ \ 10 | | | | |___ | | | |_| | | | | | | |_ ) ) ) ) 11 | |___| |_______| |___| |_______|_______|___|_| |__|___|_______| / / / / 12 | ==================================================================/_/_/_/ 13 | 14 | :: Built with Spring Boot :: ${spring-boot.version} 15 | 16 | -------------------------------------------------------------------------------- /petclinic-latest/src/main/resources/db/hsqldb/schema.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE vet_specialties IF EXISTS; 2 | DROP TABLE vets IF EXISTS; 3 | DROP TABLE specialties IF EXISTS; 4 | DROP TABLE visits IF EXISTS; 5 | DROP TABLE pets IF EXISTS; 6 | DROP TABLE types IF EXISTS; 7 | DROP TABLE owners IF EXISTS; 8 | 9 | 10 | CREATE TABLE vets ( 11 | id INTEGER IDENTITY PRIMARY KEY, 12 | first_name VARCHAR(30), 13 | last_name VARCHAR(30) 14 | ); 15 | CREATE INDEX vets_last_name ON vets (last_name); 16 | 17 | CREATE TABLE specialties ( 18 | id INTEGER IDENTITY PRIMARY KEY, 19 | name VARCHAR(80) 20 | ); 21 | CREATE INDEX specialties_name ON specialties (name); 22 | 23 | CREATE TABLE vet_specialties ( 24 | vet_id INTEGER NOT NULL, 25 | specialty_id INTEGER NOT NULL 26 | ); 27 | ALTER TABLE vet_specialties ADD CONSTRAINT fk_vet_specialties_vets FOREIGN KEY (vet_id) REFERENCES vets (id); 28 | ALTER TABLE vet_specialties ADD CONSTRAINT fk_vet_specialties_specialties FOREIGN KEY (specialty_id) REFERENCES specialties (id); 29 | 30 | CREATE TABLE types ( 31 | id INTEGER IDENTITY PRIMARY KEY, 32 | name VARCHAR(80) 33 | ); 34 | CREATE INDEX types_name ON types (name); 35 | 36 | CREATE TABLE owners ( 37 | id INTEGER IDENTITY PRIMARY KEY, 38 | first_name VARCHAR(30), 39 | last_name VARCHAR_IGNORECASE(30), 40 | address VARCHAR(255), 41 | city VARCHAR(80), 42 | telephone VARCHAR(20) 43 | ); 44 | CREATE INDEX owners_last_name ON owners (last_name); 45 | 46 | CREATE TABLE pets ( 47 | id INTEGER IDENTITY PRIMARY KEY, 48 | name VARCHAR(30), 49 | birth_date DATE, 50 | type_id INTEGER NOT NULL, 51 | owner_id INTEGER NOT NULL 52 | ); 53 | ALTER TABLE pets ADD CONSTRAINT fk_pets_owners FOREIGN KEY (owner_id) REFERENCES owners (id); 54 | ALTER TABLE pets ADD CONSTRAINT fk_pets_types FOREIGN KEY (type_id) REFERENCES types (id); 55 | CREATE INDEX pets_name ON pets (name); 56 | 57 | CREATE TABLE visits ( 58 | id INTEGER IDENTITY PRIMARY KEY, 59 | pet_id INTEGER NOT NULL, 60 | visit_date DATE, 61 | description VARCHAR(255) 62 | ); 63 | ALTER TABLE visits ADD CONSTRAINT fk_visits_pets FOREIGN KEY (pet_id) REFERENCES pets (id); 64 | CREATE INDEX visits_pet_id ON visits (pet_id); 65 | -------------------------------------------------------------------------------- /petclinic-latest/src/main/resources/db/mysql/petclinic_db_setup_mysql.txt: -------------------------------------------------------------------------------- 1 | ================================================================================ 2 | === Spring PetClinic sample application - MySQL Configuration === 3 | ================================================================================ 4 | 5 | @author Sam Brannen 6 | @author Costin Leau 7 | @author Dave Syer 8 | 9 | -------------------------------------------------------------------------------- 10 | 11 | 1) Download and install the MySQL database (e.g., MySQL Community Server 5.1.x), 12 | which can be found here: http://dev.mysql.com/downloads/ 13 | 14 | 2) Add the MySQL JDBC driver to your classpath. 15 | 16 | 3) Set "database=mysql" in "application.properties" 17 | 18 | 4) Create the PetClinic database and user by executing the "db/mysql/{schema,data}.sql" 19 | scripts (or set "spring.datasource.initialize=true" the first time you run the app. 20 | -------------------------------------------------------------------------------- /petclinic-latest/src/main/resources/db/mysql/schema.sql: -------------------------------------------------------------------------------- 1 | CREATE DATABASE IF NOT EXISTS petclinic; 2 | 3 | ALTER DATABASE petclinic 4 | DEFAULT CHARACTER SET utf8 5 | DEFAULT COLLATE utf8_general_ci; 6 | 7 | GRANT ALL PRIVILEGES ON petclinic.* TO pc@localhost IDENTIFIED BY 'pc'; 8 | 9 | USE petclinic; 10 | 11 | CREATE TABLE IF NOT EXISTS vets ( 12 | id INT(4) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, 13 | first_name VARCHAR(30), 14 | last_name VARCHAR(30), 15 | INDEX(last_name) 16 | ) engine=InnoDB; 17 | 18 | CREATE TABLE IF NOT EXISTS specialties ( 19 | id INT(4) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, 20 | name VARCHAR(80), 21 | INDEX(name) 22 | ) engine=InnoDB; 23 | 24 | CREATE TABLE IF NOT EXISTS vet_specialties ( 25 | vet_id INT(4) UNSIGNED NOT NULL, 26 | specialty_id INT(4) UNSIGNED NOT NULL, 27 | FOREIGN KEY (vet_id) REFERENCES vets(id), 28 | FOREIGN KEY (specialty_id) REFERENCES specialties(id), 29 | UNIQUE (vet_id,specialty_id) 30 | ) engine=InnoDB; 31 | 32 | CREATE TABLE IF NOT EXISTS types ( 33 | id INT(4) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, 34 | name VARCHAR(80), 35 | INDEX(name) 36 | ) engine=InnoDB; 37 | 38 | CREATE TABLE IF NOT EXISTS owners ( 39 | id INT(4) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, 40 | first_name VARCHAR(30), 41 | last_name VARCHAR(30), 42 | address VARCHAR(255), 43 | city VARCHAR(80), 44 | telephone VARCHAR(20), 45 | INDEX(last_name) 46 | ) engine=InnoDB; 47 | 48 | CREATE TABLE IF NOT EXISTS pets ( 49 | id INT(4) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, 50 | name VARCHAR(30), 51 | birth_date DATE, 52 | type_id INT(4) UNSIGNED NOT NULL, 53 | owner_id INT(4) UNSIGNED NOT NULL, 54 | INDEX(name), 55 | FOREIGN KEY (owner_id) REFERENCES owners(id), 56 | FOREIGN KEY (type_id) REFERENCES types(id) 57 | ) engine=InnoDB; 58 | 59 | CREATE TABLE IF NOT EXISTS visits ( 60 | id INT(4) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, 61 | pet_id INT(4) UNSIGNED NOT NULL, 62 | visit_date DATE, 63 | description VARCHAR(255), 64 | FOREIGN KEY (pet_id) REFERENCES pets(id) 65 | ) engine=InnoDB; 66 | -------------------------------------------------------------------------------- /petclinic-latest/src/main/resources/messages/messages.properties: -------------------------------------------------------------------------------- 1 | welcome=Welcome 2 | required=is required 3 | notFound=has not been found 4 | duplicate=is already in use 5 | nonNumeric=must be all numeric 6 | duplicateFormSubmission=Duplicate form submission is not allowed 7 | typeMismatch.date=invalid date 8 | typeMismatch.birthDate=invalid date 9 | -------------------------------------------------------------------------------- /petclinic-latest/src/main/resources/messages/messages_de.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dsyer/spring-boot-startup-bench/c68adbcb4ab70005d8a056c34ea42e0b1f7ab810/petclinic-latest/src/main/resources/messages/messages_de.properties -------------------------------------------------------------------------------- /petclinic-latest/src/main/resources/messages/messages_en.properties: -------------------------------------------------------------------------------- 1 | # This file is intentionally empty. Message look-ups will fall back to the default "messages.properties" file. -------------------------------------------------------------------------------- /petclinic-latest/src/main/resources/static/resources/fonts/montserrat-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dsyer/spring-boot-startup-bench/c68adbcb4ab70005d8a056c34ea42e0b1f7ab810/petclinic-latest/src/main/resources/static/resources/fonts/montserrat-webfont.eot -------------------------------------------------------------------------------- /petclinic-latest/src/main/resources/static/resources/fonts/montserrat-webfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dsyer/spring-boot-startup-bench/c68adbcb4ab70005d8a056c34ea42e0b1f7ab810/petclinic-latest/src/main/resources/static/resources/fonts/montserrat-webfont.ttf -------------------------------------------------------------------------------- /petclinic-latest/src/main/resources/static/resources/fonts/montserrat-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dsyer/spring-boot-startup-bench/c68adbcb4ab70005d8a056c34ea42e0b1f7ab810/petclinic-latest/src/main/resources/static/resources/fonts/montserrat-webfont.woff -------------------------------------------------------------------------------- /petclinic-latest/src/main/resources/static/resources/fonts/varela_round-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dsyer/spring-boot-startup-bench/c68adbcb4ab70005d8a056c34ea42e0b1f7ab810/petclinic-latest/src/main/resources/static/resources/fonts/varela_round-webfont.eot -------------------------------------------------------------------------------- /petclinic-latest/src/main/resources/static/resources/fonts/varela_round-webfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dsyer/spring-boot-startup-bench/c68adbcb4ab70005d8a056c34ea42e0b1f7ab810/petclinic-latest/src/main/resources/static/resources/fonts/varela_round-webfont.ttf -------------------------------------------------------------------------------- /petclinic-latest/src/main/resources/static/resources/fonts/varela_round-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dsyer/spring-boot-startup-bench/c68adbcb4ab70005d8a056c34ea42e0b1f7ab810/petclinic-latest/src/main/resources/static/resources/fonts/varela_round-webfont.woff -------------------------------------------------------------------------------- /petclinic-latest/src/main/resources/static/resources/images/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dsyer/spring-boot-startup-bench/c68adbcb4ab70005d8a056c34ea42e0b1f7ab810/petclinic-latest/src/main/resources/static/resources/images/favicon.png -------------------------------------------------------------------------------- /petclinic-latest/src/main/resources/static/resources/images/pets.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dsyer/spring-boot-startup-bench/c68adbcb4ab70005d8a056c34ea42e0b1f7ab810/petclinic-latest/src/main/resources/static/resources/images/pets.png -------------------------------------------------------------------------------- /petclinic-latest/src/main/resources/static/resources/images/platform-bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dsyer/spring-boot-startup-bench/c68adbcb4ab70005d8a056c34ea42e0b1f7ab810/petclinic-latest/src/main/resources/static/resources/images/platform-bg.png -------------------------------------------------------------------------------- /petclinic-latest/src/main/resources/static/resources/images/spring-logo-dataflow-mobile.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dsyer/spring-boot-startup-bench/c68adbcb4ab70005d8a056c34ea42e0b1f7ab810/petclinic-latest/src/main/resources/static/resources/images/spring-logo-dataflow-mobile.png -------------------------------------------------------------------------------- /petclinic-latest/src/main/resources/static/resources/images/spring-logo-dataflow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dsyer/spring-boot-startup-bench/c68adbcb4ab70005d8a056c34ea42e0b1f7ab810/petclinic-latest/src/main/resources/static/resources/images/spring-logo-dataflow.png -------------------------------------------------------------------------------- /petclinic-latest/src/main/resources/static/resources/images/spring-pivotal-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dsyer/spring-boot-startup-bench/c68adbcb4ab70005d8a056c34ea42e0b1f7ab810/petclinic-latest/src/main/resources/static/resources/images/spring-pivotal-logo.png -------------------------------------------------------------------------------- /petclinic-latest/src/main/resources/templates/error.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

Something happened...

8 |

Exception message

9 | 10 | 11 | -------------------------------------------------------------------------------- /petclinic-latest/src/main/resources/templates/fragments/inputField.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 |
8 | 9 |
10 | 12 | 15 | 16 | 19 | Error 20 | 21 |
22 |
23 |
24 |
25 | 26 | 27 | -------------------------------------------------------------------------------- /petclinic-latest/src/main/resources/templates/fragments/selectField.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 |
8 | 9 | 10 |
11 | 15 | 18 | 19 | 22 | Error 23 | 24 |
25 |
26 |
27 |
28 | 29 | -------------------------------------------------------------------------------- /petclinic-latest/src/main/resources/templates/owners/createOrUpdateOwnerForm.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 |

Owner

7 |
8 |
9 | 11 | 13 | 15 | 17 | 19 |
20 |
21 |
22 | 26 |
27 |
28 |
29 | 30 | 31 | -------------------------------------------------------------------------------- /petclinic-latest/src/main/resources/templates/owners/findOwners.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 |

Find Owners

7 | 8 |
10 |
11 |
12 | 13 |
14 |
17 |

Error

18 |
19 |
20 |
21 |
22 |
23 |
24 | 26 |
27 |
28 | 29 |
30 | 31 |
32 | Add Owner 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /petclinic-latest/src/main/resources/templates/owners/ownersList.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

Owners

8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 24 | 28 | 29 | 30 |
NameAddressCityTelephonePets
22 | 23 | 25 | 26 | 27 |
31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /petclinic-latest/src/main/resources/templates/pets/createOrUpdatePetForm.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 |

7 | New 8 | Pet 9 |

10 |
11 | 12 |
13 |
14 | 15 |
16 | 17 |
18 |
19 | 21 | 23 | 25 |
26 |
27 |
28 | 32 |
33 |
34 |
35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /petclinic-latest/src/main/resources/templates/pets/createOrUpdateVisitForm.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 |

7 | New 8 | Visit 9 |

10 | 11 | Pet 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 25 | 26 | 28 | 29 |
NameBirth DateTypeOwner
30 | 31 |
32 |
33 | 35 | 37 |
38 | 39 |
40 |
41 | 42 | 43 |
44 |
45 |
46 | 47 |
48 | Previous Visits 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 |
DateDescription
59 | 60 | 61 | -------------------------------------------------------------------------------- /petclinic-latest/src/main/resources/templates/vets/vetList.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | 8 |

Veterinarians

9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 23 | 24 | 25 |
NameSpecialties
none
26 | 27 | 28 | 29 | 31 | 32 | 33 |
View 30 | as XMLView as JSON
34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /petclinic-latest/src/main/resources/templates/welcome.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

Welcome

8 |
9 |
10 | 11 |
12 |
13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /petclinic-latest/src/main/wro/wro.properties: -------------------------------------------------------------------------------- 1 | #List of preProcessors 2 | preProcessors=lessCssImport 3 | #List of postProcessors 4 | postProcessors=less4j -------------------------------------------------------------------------------- /petclinic-latest/src/main/wro/wro.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | classpath:META-INF/resources/webjars/bootstrap/3.3.6/less/bootstrap.less 4 | /petclinic.less 5 | 6 | 7 | -------------------------------------------------------------------------------- /petclinic-latest/src/test/java/org/springframework/samples/petclinic/model/ValidatorTests.java: -------------------------------------------------------------------------------- 1 | package org.springframework.samples.petclinic.model; 2 | 3 | import static org.assertj.core.api.Assertions.assertThat; 4 | 5 | import java.util.Locale; 6 | import java.util.Set; 7 | 8 | import javax.validation.ConstraintViolation; 9 | import javax.validation.Validator; 10 | 11 | import org.junit.Test; 12 | import org.springframework.context.i18n.LocaleContextHolder; 13 | import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean; 14 | 15 | /** 16 | * @author Michael Isvy 17 | * Simple test to make sure that Bean Validation is working 18 | * (useful when upgrading to a new version of Hibernate Validator/ Bean Validation) 19 | */ 20 | public class ValidatorTests { 21 | 22 | private Validator createValidator() { 23 | LocalValidatorFactoryBean localValidatorFactoryBean = new LocalValidatorFactoryBean(); 24 | localValidatorFactoryBean.afterPropertiesSet(); 25 | return localValidatorFactoryBean; 26 | } 27 | 28 | @Test 29 | public void shouldNotValidateWhenFirstNameEmpty() { 30 | 31 | LocaleContextHolder.setLocale(Locale.ENGLISH); 32 | Person person = new Person(); 33 | person.setFirstName(""); 34 | person.setLastName("smith"); 35 | 36 | Validator validator = createValidator(); 37 | Set> constraintViolations = validator.validate(person); 38 | 39 | assertThat(constraintViolations.size()).isEqualTo(1); 40 | ConstraintViolation violation = constraintViolations.iterator().next(); 41 | assertThat(violation.getPropertyPath().toString()).isEqualTo("firstName"); 42 | assertThat(violation.getMessage()).isEqualTo("may not be empty"); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /petclinic-latest/src/test/java/org/springframework/samples/petclinic/owner/PetTypeFormatterTests.java: -------------------------------------------------------------------------------- 1 | package org.springframework.samples.petclinic.owner; 2 | 3 | import java.text.ParseException; 4 | import java.util.ArrayList; 5 | import java.util.Collection; 6 | import java.util.List; 7 | import java.util.Locale; 8 | 9 | import org.junit.Before; 10 | import org.junit.Test; 11 | import org.junit.runner.RunWith; 12 | import org.mockito.Mock; 13 | import org.mockito.Mockito; 14 | import org.mockito.junit.MockitoJUnitRunner; 15 | 16 | import static org.junit.Assert.assertEquals; 17 | 18 | /** 19 | * Test class for {@link PetTypeFormatter} 20 | * 21 | * @author Colin But 22 | */ 23 | @RunWith(MockitoJUnitRunner.class) 24 | public class PetTypeFormatterTests { 25 | 26 | @Mock 27 | private PetRepository pets; 28 | 29 | private PetTypeFormatter petTypeFormatter; 30 | 31 | @Before 32 | public void setup() { 33 | this.petTypeFormatter = new PetTypeFormatter(pets); 34 | } 35 | 36 | @Test 37 | public void testPrint() { 38 | PetType petType = new PetType(); 39 | petType.setName("Hamster"); 40 | String petTypeName = this.petTypeFormatter.print(petType, Locale.ENGLISH); 41 | assertEquals("Hamster", petTypeName); 42 | } 43 | 44 | @Test 45 | public void shouldParse() throws ParseException { 46 | Mockito.when(this.pets.findPetTypes()).thenReturn(makePetTypes()); 47 | PetType petType = petTypeFormatter.parse("Bird", Locale.ENGLISH); 48 | assertEquals("Bird", petType.getName()); 49 | } 50 | 51 | @Test(expected = ParseException.class) 52 | public void shouldThrowParseException() throws ParseException { 53 | Mockito.when(this.pets.findPetTypes()).thenReturn(makePetTypes()); 54 | petTypeFormatter.parse("Fish", Locale.ENGLISH); 55 | } 56 | 57 | /** 58 | * Helper method to produce some sample pet types just for test purpose 59 | * 60 | * @return {@link Collection} of {@link PetType} 61 | */ 62 | private List makePetTypes() { 63 | List petTypes = new ArrayList<>(); 64 | petTypes.add(new PetType() { 65 | { 66 | setName("Dog"); 67 | } 68 | }); 69 | petTypes.add(new PetType() { 70 | { 71 | setName("Bird"); 72 | } 73 | }); 74 | return petTypes; 75 | } 76 | 77 | } 78 | -------------------------------------------------------------------------------- /petclinic-latest/src/test/java/org/springframework/samples/petclinic/service/EntityUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2013 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.samples.petclinic.service; 18 | 19 | import java.util.Collection; 20 | 21 | import org.springframework.orm.ObjectRetrievalFailureException; 22 | import org.springframework.samples.petclinic.model.BaseEntity; 23 | 24 | /** 25 | * Utility methods for handling entities. Separate from the BaseEntity class mainly because of dependency on the 26 | * ORM-associated ObjectRetrievalFailureException. 27 | * 28 | * @author Juergen Hoeller 29 | * @author Sam Brannen 30 | * @see org.springframework.samples.petclinic.model.BaseEntity 31 | * @since 29.10.2003 32 | */ 33 | public abstract class EntityUtils { 34 | 35 | /** 36 | * Look up the entity of the given class with the given id in the given collection. 37 | * 38 | * @param entities the collection to search 39 | * @param entityClass the entity class to look up 40 | * @param entityId the entity id to look up 41 | * @return the found entity 42 | * @throws ObjectRetrievalFailureException if the entity was not found 43 | */ 44 | public static T getById(Collection entities, Class entityClass, int entityId) 45 | throws ObjectRetrievalFailureException { 46 | for (T entity : entities) { 47 | if (entity.getId() == entityId && entityClass.isInstance(entity)) { 48 | return entity; 49 | } 50 | } 51 | throw new ObjectRetrievalFailureException(entityClass, entityId); 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /petclinic-latest/src/test/java/org/springframework/samples/petclinic/system/CrashControllerTests.java: -------------------------------------------------------------------------------- 1 | package org.springframework.samples.petclinic.system; 2 | 3 | import org.junit.Before; 4 | import org.junit.Ignore; 5 | import org.junit.Test; 6 | import org.junit.runner.RunWith; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.boot.test.context.SpringBootTest; 9 | import org.springframework.samples.petclinic.PetClinicApplication; 10 | import org.springframework.samples.petclinic.system.CrashController; 11 | import org.springframework.test.context.junit4.SpringRunner; 12 | import org.springframework.test.context.web.WebAppConfiguration; 13 | import org.springframework.test.web.servlet.MockMvc; 14 | import org.springframework.test.web.servlet.setup.MockMvcBuilders; 15 | 16 | import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; 17 | import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; 18 | 19 | /** 20 | * Test class for {@link CrashController} 21 | * 22 | * @author Colin But 23 | */ 24 | @RunWith(SpringRunner.class) 25 | @SpringBootTest(classes = PetClinicApplication.class) 26 | @WebAppConfiguration 27 | // Waiting https://github.com/spring-projects/spring-boot/issues/5574 28 | @Ignore 29 | public class CrashControllerTests { 30 | 31 | @Autowired 32 | private CrashController crashController; 33 | 34 | private MockMvc mockMvc; 35 | 36 | @Before 37 | public void setup() { 38 | this.mockMvc = MockMvcBuilders 39 | .standaloneSetup(crashController) 40 | //.setHandlerExceptionResolvers(new SimpleMappingExceptionResolver()) 41 | .build(); 42 | } 43 | 44 | @Test 45 | public void testTriggerException() throws Exception { 46 | mockMvc.perform(get("/oups")) 47 | .andExpect(view().name("exception")) 48 | .andExpect(model().attributeExists("exception")) 49 | .andExpect(forwardedUrl("exception")) 50 | .andExpect(status().isOk()); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /petclinic/.editorconfig: -------------------------------------------------------------------------------- 1 | # top-most EditorConfig file 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | end_of_line = lf 7 | insert_final_newline = true 8 | indent_style = space 9 | 10 | [*.{java,xml}] 11 | indent_size = 4 12 | trim_trailing_whitespace = true 13 | -------------------------------------------------------------------------------- /petclinic/.travis.yml: -------------------------------------------------------------------------------- 1 | language: java 2 | jdk: oraclejdk8 3 | -------------------------------------------------------------------------------- /petclinic/sonar-project.properties: -------------------------------------------------------------------------------- 1 | # Required metadata 2 | sonar.projectKey=java-sonar-runner-simple 3 | sonar.projectName=Simple Java project analyzed with the SonarQube Runner 4 | sonar.projectVersion=1.0 5 | 6 | # Comma-separated paths to directories with sources (required) 7 | sonar.sources=src 8 | 9 | # Language 10 | sonar.language=java 11 | 12 | # Encoding of the source files 13 | sonar.sourceEncoding=UTF-8 -------------------------------------------------------------------------------- /petclinic/src/main/java/org/springframework/samples/petclinic/PetClinicApplication.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2014 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.samples.petclinic; 18 | 19 | import org.springframework.boot.SpringApplication; 20 | import org.springframework.boot.autoconfigure.SpringBootApplication; 21 | 22 | /** 23 | * PetClinic Spring Boot Application. 24 | * 25 | * @author Dave Syer 26 | * 27 | */ 28 | @SpringBootApplication 29 | public class PetClinicApplication { 30 | 31 | public static void main(String[] args) throws Exception { 32 | SpringApplication.run(PetClinicApplication.class, args); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /petclinic/src/main/java/org/springframework/samples/petclinic/model/BaseEntity.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2013 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.samples.petclinic.model; 17 | 18 | import javax.persistence.GeneratedValue; 19 | import javax.persistence.GenerationType; 20 | import javax.persistence.Id; 21 | import javax.persistence.MappedSuperclass; 22 | 23 | /** 24 | * Simple JavaBean domain object with an id property. Used as a base class for objects needing this property. 25 | * 26 | * @author Ken Krebs 27 | * @author Juergen Hoeller 28 | */ 29 | @MappedSuperclass 30 | public class BaseEntity { 31 | @Id 32 | @GeneratedValue(strategy = GenerationType.IDENTITY) 33 | protected Integer id; 34 | 35 | public Integer getId() { 36 | return id; 37 | } 38 | 39 | public void setId(Integer id) { 40 | this.id = id; 41 | } 42 | 43 | public boolean isNew() { 44 | return this.id == null; 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /petclinic/src/main/java/org/springframework/samples/petclinic/model/NamedEntity.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2013 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.samples.petclinic.model; 17 | 18 | import javax.persistence.Column; 19 | import javax.persistence.MappedSuperclass; 20 | 21 | 22 | /** 23 | * Simple JavaBean domain object adds a name property to BaseEntity. Used as a base class for objects 24 | * needing these properties. 25 | * 26 | * @author Ken Krebs 27 | * @author Juergen Hoeller 28 | */ 29 | @MappedSuperclass 30 | public class NamedEntity extends BaseEntity { 31 | 32 | @Column(name = "name") 33 | private String name; 34 | 35 | public String getName() { 36 | return this.name; 37 | } 38 | 39 | public void setName(String name) { 40 | this.name = name; 41 | } 42 | 43 | @Override 44 | public String toString() { 45 | return this.getName(); 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /petclinic/src/main/java/org/springframework/samples/petclinic/model/Person.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2013 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.samples.petclinic.model; 17 | 18 | import javax.persistence.Column; 19 | import javax.persistence.MappedSuperclass; 20 | 21 | import org.hibernate.validator.constraints.NotEmpty; 22 | 23 | /** 24 | * Simple JavaBean domain object representing an person. 25 | * 26 | * @author Ken Krebs 27 | */ 28 | @MappedSuperclass 29 | public class Person extends BaseEntity { 30 | 31 | @Column(name = "first_name") 32 | @NotEmpty 33 | protected String firstName; 34 | 35 | @Column(name = "last_name") 36 | @NotEmpty 37 | protected String lastName; 38 | 39 | public String getFirstName() { 40 | return this.firstName; 41 | } 42 | 43 | public void setFirstName(String firstName) { 44 | this.firstName = firstName; 45 | } 46 | 47 | public String getLastName() { 48 | return this.lastName; 49 | } 50 | 51 | public void setLastName(String lastName) { 52 | this.lastName = lastName; 53 | } 54 | 55 | 56 | } 57 | -------------------------------------------------------------------------------- /petclinic/src/main/java/org/springframework/samples/petclinic/model/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * The classes in this package represent utilities used by the domain. 3 | */ 4 | package org.springframework.samples.petclinic.model; 5 | 6 | -------------------------------------------------------------------------------- /petclinic/src/main/java/org/springframework/samples/petclinic/owner/PetRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2013 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.samples.petclinic.owner; 17 | 18 | import java.util.List; 19 | 20 | import org.springframework.data.jpa.repository.Query; 21 | import org.springframework.data.repository.Repository; 22 | import org.springframework.transaction.annotation.Transactional; 23 | 24 | /** 25 | * Repository class for Pet domain objects All method names are compliant with Spring Data naming 26 | * conventions so this interface can easily be extended for Spring Data See here: http://static.springsource.org/spring-data/jpa/docs/current/reference/html/jpa.repositories.html#jpa.query-methods.query-creation 27 | * 28 | * @author Ken Krebs 29 | * @author Juergen Hoeller 30 | * @author Sam Brannen 31 | * @author Michael Isvy 32 | */ 33 | public interface PetRepository extends Repository { 34 | 35 | /** 36 | * Retrieve all {@link PetType}s from the data store. 37 | * @return a Collection of {@link PetType}s. 38 | */ 39 | @Query("SELECT ptype FROM PetType ptype ORDER BY ptype.name") 40 | @Transactional(readOnly = true) 41 | List findPetTypes(); 42 | 43 | /** 44 | * Retrieve a {@link Pet} from the data store by id. 45 | * @param id the id to search for 46 | * @return the {@link Pet} if found 47 | */ 48 | @Transactional(readOnly = true) 49 | Pet findById(Integer id); 50 | 51 | /** 52 | * Save a {@link Pet} to the data store, either inserting or updating it. 53 | * @param pet the {@link Pet} to save 54 | */ 55 | void save(Pet pet); 56 | 57 | } 58 | 59 | -------------------------------------------------------------------------------- /petclinic/src/main/java/org/springframework/samples/petclinic/owner/PetType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2013 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.samples.petclinic.owner; 17 | 18 | import javax.persistence.Entity; 19 | import javax.persistence.Table; 20 | 21 | import org.springframework.samples.petclinic.model.NamedEntity; 22 | 23 | /** 24 | * @author Juergen Hoeller 25 | * Can be Cat, Dog, Hamster... 26 | */ 27 | @Entity 28 | @Table(name = "types") 29 | public class PetType extends NamedEntity { 30 | 31 | } 32 | -------------------------------------------------------------------------------- /petclinic/src/main/java/org/springframework/samples/petclinic/owner/PetTypeFormatter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2013 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.samples.petclinic.owner; 17 | 18 | 19 | import java.text.ParseException; 20 | import java.util.Collection; 21 | import java.util.Locale; 22 | 23 | import org.springframework.beans.factory.annotation.Autowired; 24 | import org.springframework.format.Formatter; 25 | import org.springframework.stereotype.Component; 26 | 27 | /** 28 | * Instructs Spring MVC on how to parse and print elements of type 'PetType'. Starting from Spring 3.0, Formatters have 29 | * come as an improvement in comparison to legacy PropertyEditors. See the following links for more details: - The 30 | * Spring ref doc: http://static.springsource.org/spring/docs/current/spring-framework-reference/html/validation.html#format-Formatter-SPI 31 | * - A nice blog entry from Gordon Dickens: http://gordondickens.com/wordpress/2010/09/30/using-spring-3-0-custom-type-converter/ 32 | *

33 | * 34 | * @author Mark Fisher 35 | * @author Juergen Hoeller 36 | * @author Michael Isvy 37 | */ 38 | @Component 39 | public class PetTypeFormatter implements Formatter { 40 | 41 | private final PetRepository pets; 42 | 43 | 44 | @Autowired 45 | public PetTypeFormatter(PetRepository pets) { 46 | this.pets = pets; 47 | } 48 | 49 | @Override 50 | public String print(PetType petType, Locale locale) { 51 | return petType.getName(); 52 | } 53 | 54 | @Override 55 | public PetType parse(String text, Locale locale) throws ParseException { 56 | Collection findPetTypes = this.pets.findPetTypes(); 57 | for (PetType type : findPetTypes) { 58 | if (type.getName().equals(text)) { 59 | return type; 60 | } 61 | } 62 | throw new ParseException("type not found: " + text, 0); 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /petclinic/src/main/java/org/springframework/samples/petclinic/owner/PetValidator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2013 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.samples.petclinic.owner; 17 | 18 | import org.springframework.util.StringUtils; 19 | import org.springframework.validation.Errors; 20 | import org.springframework.validation.Validator; 21 | 22 | /** 23 | * Validator for Pet forms. 24 | *

25 | * We're not using Bean Validation annotations here because it is easier to define such validation rule in Java. 26 | *

27 | * 28 | * @author Ken Krebs 29 | * @author Juergen Hoeller 30 | */ 31 | public class PetValidator implements Validator { 32 | 33 | private static final String REQUIRED = "required"; 34 | 35 | @Override 36 | public void validate(Object obj, Errors errors) { 37 | Pet pet = (Pet) obj; 38 | String name = pet.getName(); 39 | // name validation 40 | if (!StringUtils.hasLength(name)) { 41 | errors.rejectValue("name", REQUIRED, REQUIRED); 42 | } 43 | 44 | // type validation 45 | if (pet.isNew() && pet.getType() == null) { 46 | errors.rejectValue("type", REQUIRED, REQUIRED); 47 | } 48 | 49 | // birth date validation 50 | if (pet.getBirthDate() == null) { 51 | errors.rejectValue("birthDate", REQUIRED, REQUIRED); 52 | } 53 | } 54 | 55 | /** 56 | * This Validator validates *just* Pet instances 57 | */ 58 | @Override 59 | public boolean supports(Class clazz) { 60 | return Pet.class.isAssignableFrom(clazz); 61 | } 62 | 63 | 64 | } 65 | -------------------------------------------------------------------------------- /petclinic/src/main/java/org/springframework/samples/petclinic/system/CacheConfig.java: -------------------------------------------------------------------------------- 1 | package org.springframework.samples.petclinic.system; 2 | 3 | import org.springframework.cache.annotation.EnableCaching; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.context.annotation.Profile; 6 | 7 | /** 8 | * Cache could be disable in unit test. 9 | */ 10 | @Configuration 11 | @EnableCaching 12 | @Profile("production") 13 | class CacheConfig { 14 | } 15 | -------------------------------------------------------------------------------- /petclinic/src/main/java/org/springframework/samples/petclinic/system/CrashController.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2013 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.samples.petclinic.system; 17 | 18 | import org.springframework.stereotype.Controller; 19 | import org.springframework.web.bind.annotation.RequestMapping; 20 | import org.springframework.web.bind.annotation.RequestMethod; 21 | 22 | /** 23 | * Controller used to showcase what happens when an exception is thrown 24 | * 25 | * @author Michael Isvy 26 | *

27 | * Also see how a view that resolves to "error" has been added ("error.html"). 28 | */ 29 | @Controller 30 | class CrashController { 31 | 32 | @RequestMapping(value = "/oups", method = RequestMethod.GET) 33 | public String triggerException() { 34 | throw new RuntimeException( 35 | "Expected: controller used to showcase what " + "happens when an exception is thrown"); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /petclinic/src/main/java/org/springframework/samples/petclinic/system/WelcomeController.java: -------------------------------------------------------------------------------- 1 | package org.springframework.samples.petclinic.system; 2 | 3 | 4 | import org.springframework.stereotype.Controller; 5 | import org.springframework.web.bind.annotation.RequestMapping; 6 | 7 | @Controller 8 | class WelcomeController { 9 | 10 | @RequestMapping("/") 11 | public String welcome() { 12 | return "welcome"; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /petclinic/src/main/java/org/springframework/samples/petclinic/vet/Specialty.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2013 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.samples.petclinic.vet; 17 | 18 | import javax.persistence.Entity; 19 | import javax.persistence.Table; 20 | 21 | import org.springframework.samples.petclinic.model.NamedEntity; 22 | 23 | /** 24 | * Models a {@link Vet Vet's} specialty (for example, dentistry). 25 | * 26 | * @author Juergen Hoeller 27 | */ 28 | @Entity 29 | @Table(name = "specialties") 30 | public class Specialty extends NamedEntity { 31 | 32 | } 33 | -------------------------------------------------------------------------------- /petclinic/src/main/java/org/springframework/samples/petclinic/vet/VetController.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2013 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.samples.petclinic.vet; 17 | 18 | import java.util.Map; 19 | 20 | import org.springframework.beans.factory.annotation.Autowired; 21 | import org.springframework.stereotype.Controller; 22 | import org.springframework.web.bind.annotation.RequestMapping; 23 | import org.springframework.web.bind.annotation.ResponseBody; 24 | 25 | /** 26 | * @author Juergen Hoeller 27 | * @author Mark Fisher 28 | * @author Ken Krebs 29 | * @author Arjen Poutsma 30 | */ 31 | @Controller 32 | class VetController { 33 | 34 | private final VetRepository vets; 35 | 36 | @Autowired 37 | public VetController(VetRepository clinicService) { 38 | this.vets = clinicService; 39 | } 40 | 41 | @RequestMapping(value = { "/vets.html" }) 42 | public String showVetList(Map model) { 43 | // Here we are returning an object of type 'Vets' rather than a collection of Vet 44 | // objects so it is simpler for Object-Xml mapping 45 | Vets vets = new Vets(); 46 | vets.getVetList().addAll(this.vets.findAll()); 47 | model.put("vets", vets); 48 | return "vets/vetList"; 49 | } 50 | 51 | @RequestMapping(value = { "/vets.json", "/vets.xml" }) 52 | public @ResponseBody Vets showResourcesVetList() { 53 | // Here we are returning an object of type 'Vets' rather than a collection of Vet 54 | // objects so it is simpler for JSon/Object mapping 55 | Vets vets = new Vets(); 56 | vets.getVetList().addAll(this.vets.findAll()); 57 | return vets; 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /petclinic/src/main/java/org/springframework/samples/petclinic/vet/VetRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2013 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.samples.petclinic.vet; 17 | 18 | import java.util.Collection; 19 | 20 | import org.springframework.cache.annotation.Cacheable; 21 | import org.springframework.dao.DataAccessException; 22 | import org.springframework.data.repository.Repository; 23 | import org.springframework.transaction.annotation.Transactional; 24 | 25 | /** 26 | * Repository class for Vet domain objects All method names are compliant with Spring Data naming 27 | * conventions so this interface can easily be extended for Spring Data See here: http://static.springsource.org/spring-data/jpa/docs/current/reference/html/jpa.repositories.html#jpa.query-methods.query-creation 28 | * 29 | * @author Ken Krebs 30 | * @author Juergen Hoeller 31 | * @author Sam Brannen 32 | * @author Michael Isvy 33 | */ 34 | public interface VetRepository extends Repository { 35 | 36 | /** 37 | * Retrieve all Vets from the data store. 38 | * 39 | * @return a Collection of Vets 40 | */ 41 | @Transactional(readOnly = true) 42 | @Cacheable("vets") 43 | Collection findAll() throws DataAccessException; 44 | 45 | 46 | } 47 | -------------------------------------------------------------------------------- /petclinic/src/main/java/org/springframework/samples/petclinic/vet/Vets.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2013 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.samples.petclinic.vet; 17 | 18 | import java.util.ArrayList; 19 | import java.util.List; 20 | 21 | import javax.xml.bind.annotation.XmlElement; 22 | import javax.xml.bind.annotation.XmlRootElement; 23 | 24 | /** 25 | * Simple domain object representing a list of veterinarians. Mostly here to be used for the 'vets' {@link 26 | * org.springframework.web.servlet.view.xml.MarshallingView}. 27 | * 28 | * @author Arjen Poutsma 29 | */ 30 | @XmlRootElement 31 | public class Vets { 32 | 33 | private List vets; 34 | 35 | @XmlElement 36 | public List getVetList() { 37 | if (vets == null) { 38 | vets = new ArrayList<>(); 39 | } 40 | return vets; 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /petclinic/src/main/java/org/springframework/samples/petclinic/visit/VisitRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2013 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.samples.petclinic.visit; 17 | 18 | import java.util.List; 19 | 20 | import org.springframework.dao.DataAccessException; 21 | import org.springframework.data.repository.Repository; 22 | import org.springframework.samples.petclinic.model.BaseEntity; 23 | 24 | /** 25 | * Repository class for Visit domain objects All method names are compliant with Spring Data naming 26 | * conventions so this interface can easily be extended for Spring Data See here: http://static.springsource.org/spring-data/jpa/docs/current/reference/html/jpa.repositories.html#jpa.query-methods.query-creation 27 | * 28 | * @author Ken Krebs 29 | * @author Juergen Hoeller 30 | * @author Sam Brannen 31 | * @author Michael Isvy 32 | */ 33 | public interface VisitRepository extends Repository { 34 | 35 | /** 36 | * Save a Visit to the data store, either inserting or updating it. 37 | * 38 | * @param visit the Visit to save 39 | * @see BaseEntity#isNew 40 | */ 41 | void save(Visit visit) throws DataAccessException; 42 | 43 | List findByPetId(Integer petId); 44 | 45 | } 46 | -------------------------------------------------------------------------------- /petclinic/src/main/less/header.less: -------------------------------------------------------------------------------- 1 | .navbar { 2 | border-top: 4px solid #6db33f; 3 | background-color: #34302d; 4 | margin-bottom: 0px; 5 | border-bottom: 0; 6 | border-left: 0; 7 | border-right: 0; 8 | } 9 | 10 | .navbar a.navbar-brand { 11 | background: url("../images/spring-logo-dataflow.png") -1px -1px no-repeat; 12 | margin: 12px 0 6px; 13 | width: 229px; 14 | height: 46px; 15 | display: inline-block; 16 | text-decoration: none; 17 | padding: 0; 18 | } 19 | 20 | .navbar a.navbar-brand span { 21 | display: block; 22 | width: 229px; 23 | height: 46px; 24 | background: url("../images/spring-logo-dataflow.png") -1px -48px no-repeat; 25 | opacity: 0; 26 | -moz-transition: opacity 0.12s ease-in-out; 27 | -webkit-transition: opacity 0.12s ease-in-out; 28 | -o-transition: opacity 0.12s ease-in-out; 29 | } 30 | 31 | .navbar a:hover.navbar-brand span { 32 | opacity: 1; 33 | } 34 | 35 | .navbar li > a, .navbar-text { 36 | font-family: "montserratregular", sans-serif; 37 | text-shadow: none; 38 | font-size: 14px; 39 | 40 | /* line-height: 14px; */ 41 | padding: 28px 20px; 42 | transition: all 0.15s; 43 | -webkit-transition: all 0.15s; 44 | -moz-transition: all 0.15s; 45 | -o-transition: all 0.15s; 46 | -ms-transition: all 0.15s; 47 | } 48 | 49 | .navbar li > a { 50 | text-transform: uppercase; 51 | } 52 | 53 | .navbar .navbar-text { 54 | margin-top: 0; 55 | margin-bottom: 0; 56 | } 57 | .navbar li:hover > a { 58 | color: #eeeeee; 59 | background-color: #6db33f; 60 | } 61 | 62 | .navbar-toggle { 63 | border-width: 0; 64 | 65 | .icon-bar + .icon-bar { 66 | margin-top: 3px; 67 | } 68 | .icon-bar { 69 | width: 19px; 70 | height: 3px; 71 | } 72 | 73 | } 74 | -------------------------------------------------------------------------------- /petclinic/src/main/less/responsive.less: -------------------------------------------------------------------------------- 1 | @media (max-width: 768px) { 2 | .navbar-toggle { 3 | position:absolute; 4 | z-index: 9999; 5 | left:0px; 6 | top:0px; 7 | } 8 | 9 | .navbar a.navbar-brand { 10 | display: block; 11 | margin: 0 auto 0 auto; 12 | width: 148px; 13 | height: 50px; 14 | float: none; 15 | background: url("../images/spring-logo-dataflow-mobile.png") 0 center no-repeat; 16 | } 17 | 18 | .homepage-billboard .homepage-subtitle { 19 | font-size: 21px; 20 | line-height: 21px; 21 | } 22 | 23 | .navbar a.navbar-brand span { 24 | display: none; 25 | } 26 | 27 | .navbar { 28 | border-top-width: 0; 29 | } 30 | 31 | .xd-container { 32 | margin-top: 20px; 33 | margin-bottom: 30px; 34 | } 35 | 36 | .index-page--subtitle { 37 | margin-top: 10px; 38 | margin-bottom: 30px; 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /petclinic/src/main/less/typography.less: -------------------------------------------------------------------------------- 1 | @font-face { 2 | font-family: 'varela_roundregular'; 3 | 4 | src: url('../fonts/varela_round-webfont.eot'); 5 | src: url('../fonts/varela_round-webfont.eot?#iefix') format('embedded-opentype'), 6 | url('../fonts/varela_round-webfont.woff') format('woff'), 7 | url('../fonts/varela_round-webfont.ttf') format('truetype'), 8 | url('../fonts/varela_round-webfont.svg#varela_roundregular') format('svg'); 9 | font-weight: normal; 10 | font-style: normal; 11 | } 12 | 13 | @font-face { 14 | font-family: 'montserratregular'; 15 | src: url('../fonts/montserrat-webfont.eot'); 16 | src: url('../fonts/montserrat-webfont.eot?#iefix') format('embedded-opentype'), 17 | url('../fonts/montserrat-webfont.woff') format('woff'), 18 | url('../fonts/montserrat-webfont.ttf') format('truetype'), 19 | url('../fonts/montserrat-webfont.svg#montserratregular') format('svg'); 20 | font-weight: normal; 21 | font-style: normal; 22 | } 23 | 24 | body, h1, h2, h3, p, input { 25 | margin: 0; 26 | font-weight: 400; 27 | font-family: "varela_roundregular", sans-serif; 28 | color: #34302d; 29 | } 30 | 31 | h1 { 32 | font-size: 24px; 33 | line-height: 30px; 34 | font-family: "montserratregular", sans-serif; 35 | } 36 | 37 | h2 { 38 | font-size: 18px; 39 | font-weight: 700; 40 | line-height: 24px; 41 | margin-bottom: 10px; 42 | font-family: "montserratregular", sans-serif; 43 | } 44 | 45 | h3 { 46 | font-size: 16px; 47 | line-height: 24px; 48 | margin-bottom: 10px; 49 | font-weight: 700; 50 | } 51 | 52 | p { 53 | //font-size: 15px; 54 | //line-height: 24px; 55 | } 56 | 57 | strong { 58 | font-weight: 700; 59 | font-family: "montserratregular", sans-serif; 60 | } 61 | -------------------------------------------------------------------------------- /petclinic/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | # database init, supports mysql too 2 | database=hsqldb 3 | spring.datasource.schema=classpath*:db/${database}/schema.sql 4 | spring.datasource.data=classpath*:db/${database}/data.sql 5 | 6 | # Web 7 | spring.thymeleaf.mode=HTML 8 | 9 | # JPA 10 | spring.jpa.hibernate.ddl-auto=none 11 | 12 | # Internationalization 13 | spring.messages.basename=messages/messages 14 | 15 | # Actuator / Management 16 | management.contextPath=/manage 17 | 18 | # Logging 19 | # logging.level.org.springframework.context.annotation=TRACE 20 | 21 | # Active Spring profiles 22 | spring.profiles.active=production 23 | spring.cache.cache-names=vets -------------------------------------------------------------------------------- /petclinic/src/main/resources/banner.txt: -------------------------------------------------------------------------------- 1 | 2 | 3 | |\ _,,,--,,_ 4 | /,`.-'`' ._ \-;;,_ 5 | _______ __|,4- ) )_ .;.(__`'-'__ ___ __ _ ___ _______ 6 | | | '---''(_/._)-'(_\_) | | | | | | | | | 7 | | _ | ___|_ _| | | | | |_| | | | __ _ _ 8 | | |_| | |___ | | | | | | | | | | \ \ \ \ 9 | | ___| ___| | | | _| |___| | _ | | _| \ \ \ \ 10 | | | | |___ | | | |_| | | | | | | |_ ) ) ) ) 11 | |___| |_______| |___| |_______|_______|___|_| |__|___|_______| / / / / 12 | ==================================================================/_/_/_/ 13 | 14 | :: Built with Spring Boot :: ${spring-boot.version} 15 | 16 | -------------------------------------------------------------------------------- /petclinic/src/main/resources/db/hsqldb/schema.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE vet_specialties IF EXISTS; 2 | DROP TABLE vets IF EXISTS; 3 | DROP TABLE specialties IF EXISTS; 4 | DROP TABLE visits IF EXISTS; 5 | DROP TABLE pets IF EXISTS; 6 | DROP TABLE types IF EXISTS; 7 | DROP TABLE owners IF EXISTS; 8 | 9 | 10 | CREATE TABLE vets ( 11 | id INTEGER IDENTITY PRIMARY KEY, 12 | first_name VARCHAR(30), 13 | last_name VARCHAR(30) 14 | ); 15 | CREATE INDEX vets_last_name ON vets (last_name); 16 | 17 | CREATE TABLE specialties ( 18 | id INTEGER IDENTITY PRIMARY KEY, 19 | name VARCHAR(80) 20 | ); 21 | CREATE INDEX specialties_name ON specialties (name); 22 | 23 | CREATE TABLE vet_specialties ( 24 | vet_id INTEGER NOT NULL, 25 | specialty_id INTEGER NOT NULL 26 | ); 27 | ALTER TABLE vet_specialties ADD CONSTRAINT fk_vet_specialties_vets FOREIGN KEY (vet_id) REFERENCES vets (id); 28 | ALTER TABLE vet_specialties ADD CONSTRAINT fk_vet_specialties_specialties FOREIGN KEY (specialty_id) REFERENCES specialties (id); 29 | 30 | CREATE TABLE types ( 31 | id INTEGER IDENTITY PRIMARY KEY, 32 | name VARCHAR(80) 33 | ); 34 | CREATE INDEX types_name ON types (name); 35 | 36 | CREATE TABLE owners ( 37 | id INTEGER IDENTITY PRIMARY KEY, 38 | first_name VARCHAR(30), 39 | last_name VARCHAR_IGNORECASE(30), 40 | address VARCHAR(255), 41 | city VARCHAR(80), 42 | telephone VARCHAR(20) 43 | ); 44 | CREATE INDEX owners_last_name ON owners (last_name); 45 | 46 | CREATE TABLE pets ( 47 | id INTEGER IDENTITY PRIMARY KEY, 48 | name VARCHAR(30), 49 | birth_date DATE, 50 | type_id INTEGER NOT NULL, 51 | owner_id INTEGER NOT NULL 52 | ); 53 | ALTER TABLE pets ADD CONSTRAINT fk_pets_owners FOREIGN KEY (owner_id) REFERENCES owners (id); 54 | ALTER TABLE pets ADD CONSTRAINT fk_pets_types FOREIGN KEY (type_id) REFERENCES types (id); 55 | CREATE INDEX pets_name ON pets (name); 56 | 57 | CREATE TABLE visits ( 58 | id INTEGER IDENTITY PRIMARY KEY, 59 | pet_id INTEGER NOT NULL, 60 | visit_date DATE, 61 | description VARCHAR(255) 62 | ); 63 | ALTER TABLE visits ADD CONSTRAINT fk_visits_pets FOREIGN KEY (pet_id) REFERENCES pets (id); 64 | CREATE INDEX visits_pet_id ON visits (pet_id); 65 | -------------------------------------------------------------------------------- /petclinic/src/main/resources/db/mysql/petclinic_db_setup_mysql.txt: -------------------------------------------------------------------------------- 1 | ================================================================================ 2 | === Spring PetClinic sample application - MySQL Configuration === 3 | ================================================================================ 4 | 5 | @author Sam Brannen 6 | @author Costin Leau 7 | @author Dave Syer 8 | 9 | -------------------------------------------------------------------------------- 10 | 11 | 1) Download and install the MySQL database (e.g., MySQL Community Server 5.1.x), 12 | which can be found here: http://dev.mysql.com/downloads/ 13 | 14 | 2) Add the MySQL JDBC driver to your classpath. 15 | 16 | 3) Set "database=mysql" in "application.properties" 17 | 18 | 4) Create the PetClinic database and user by executing the "db/mysql/{schema,data}.sql" 19 | scripts (or set "spring.datasource.initialize=true" the first time you run the app. 20 | -------------------------------------------------------------------------------- /petclinic/src/main/resources/db/mysql/schema.sql: -------------------------------------------------------------------------------- 1 | CREATE DATABASE IF NOT EXISTS petclinic; 2 | 3 | ALTER DATABASE petclinic 4 | DEFAULT CHARACTER SET utf8 5 | DEFAULT COLLATE utf8_general_ci; 6 | 7 | GRANT ALL PRIVILEGES ON petclinic.* TO pc@localhost IDENTIFIED BY 'pc'; 8 | 9 | USE petclinic; 10 | 11 | CREATE TABLE IF NOT EXISTS vets ( 12 | id INT(4) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, 13 | first_name VARCHAR(30), 14 | last_name VARCHAR(30), 15 | INDEX(last_name) 16 | ) engine=InnoDB; 17 | 18 | CREATE TABLE IF NOT EXISTS specialties ( 19 | id INT(4) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, 20 | name VARCHAR(80), 21 | INDEX(name) 22 | ) engine=InnoDB; 23 | 24 | CREATE TABLE IF NOT EXISTS vet_specialties ( 25 | vet_id INT(4) UNSIGNED NOT NULL, 26 | specialty_id INT(4) UNSIGNED NOT NULL, 27 | FOREIGN KEY (vet_id) REFERENCES vets(id), 28 | FOREIGN KEY (specialty_id) REFERENCES specialties(id), 29 | UNIQUE (vet_id,specialty_id) 30 | ) engine=InnoDB; 31 | 32 | CREATE TABLE IF NOT EXISTS types ( 33 | id INT(4) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, 34 | name VARCHAR(80), 35 | INDEX(name) 36 | ) engine=InnoDB; 37 | 38 | CREATE TABLE IF NOT EXISTS owners ( 39 | id INT(4) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, 40 | first_name VARCHAR(30), 41 | last_name VARCHAR(30), 42 | address VARCHAR(255), 43 | city VARCHAR(80), 44 | telephone VARCHAR(20), 45 | INDEX(last_name) 46 | ) engine=InnoDB; 47 | 48 | CREATE TABLE IF NOT EXISTS pets ( 49 | id INT(4) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, 50 | name VARCHAR(30), 51 | birth_date DATE, 52 | type_id INT(4) UNSIGNED NOT NULL, 53 | owner_id INT(4) UNSIGNED NOT NULL, 54 | INDEX(name), 55 | FOREIGN KEY (owner_id) REFERENCES owners(id), 56 | FOREIGN KEY (type_id) REFERENCES types(id) 57 | ) engine=InnoDB; 58 | 59 | CREATE TABLE IF NOT EXISTS visits ( 60 | id INT(4) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, 61 | pet_id INT(4) UNSIGNED NOT NULL, 62 | visit_date DATE, 63 | description VARCHAR(255), 64 | FOREIGN KEY (pet_id) REFERENCES pets(id) 65 | ) engine=InnoDB; 66 | -------------------------------------------------------------------------------- /petclinic/src/main/resources/messages/messages.properties: -------------------------------------------------------------------------------- 1 | welcome=Welcome 2 | required=is required 3 | notFound=has not been found 4 | duplicate=is already in use 5 | nonNumeric=must be all numeric 6 | duplicateFormSubmission=Duplicate form submission is not allowed 7 | typeMismatch.date=invalid date 8 | typeMismatch.birthDate=invalid date 9 | -------------------------------------------------------------------------------- /petclinic/src/main/resources/messages/messages_de.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dsyer/spring-boot-startup-bench/c68adbcb4ab70005d8a056c34ea42e0b1f7ab810/petclinic/src/main/resources/messages/messages_de.properties -------------------------------------------------------------------------------- /petclinic/src/main/resources/messages/messages_en.properties: -------------------------------------------------------------------------------- 1 | # This file is intentionally empty. Message look-ups will fall back to the default "messages.properties" file. -------------------------------------------------------------------------------- /petclinic/src/main/resources/static/resources/fonts/montserrat-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dsyer/spring-boot-startup-bench/c68adbcb4ab70005d8a056c34ea42e0b1f7ab810/petclinic/src/main/resources/static/resources/fonts/montserrat-webfont.eot -------------------------------------------------------------------------------- /petclinic/src/main/resources/static/resources/fonts/montserrat-webfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dsyer/spring-boot-startup-bench/c68adbcb4ab70005d8a056c34ea42e0b1f7ab810/petclinic/src/main/resources/static/resources/fonts/montserrat-webfont.ttf -------------------------------------------------------------------------------- /petclinic/src/main/resources/static/resources/fonts/montserrat-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dsyer/spring-boot-startup-bench/c68adbcb4ab70005d8a056c34ea42e0b1f7ab810/petclinic/src/main/resources/static/resources/fonts/montserrat-webfont.woff -------------------------------------------------------------------------------- /petclinic/src/main/resources/static/resources/fonts/varela_round-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dsyer/spring-boot-startup-bench/c68adbcb4ab70005d8a056c34ea42e0b1f7ab810/petclinic/src/main/resources/static/resources/fonts/varela_round-webfont.eot -------------------------------------------------------------------------------- /petclinic/src/main/resources/static/resources/fonts/varela_round-webfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dsyer/spring-boot-startup-bench/c68adbcb4ab70005d8a056c34ea42e0b1f7ab810/petclinic/src/main/resources/static/resources/fonts/varela_round-webfont.ttf -------------------------------------------------------------------------------- /petclinic/src/main/resources/static/resources/fonts/varela_round-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dsyer/spring-boot-startup-bench/c68adbcb4ab70005d8a056c34ea42e0b1f7ab810/petclinic/src/main/resources/static/resources/fonts/varela_round-webfont.woff -------------------------------------------------------------------------------- /petclinic/src/main/resources/static/resources/images/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dsyer/spring-boot-startup-bench/c68adbcb4ab70005d8a056c34ea42e0b1f7ab810/petclinic/src/main/resources/static/resources/images/favicon.png -------------------------------------------------------------------------------- /petclinic/src/main/resources/static/resources/images/pets.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dsyer/spring-boot-startup-bench/c68adbcb4ab70005d8a056c34ea42e0b1f7ab810/petclinic/src/main/resources/static/resources/images/pets.png -------------------------------------------------------------------------------- /petclinic/src/main/resources/static/resources/images/platform-bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dsyer/spring-boot-startup-bench/c68adbcb4ab70005d8a056c34ea42e0b1f7ab810/petclinic/src/main/resources/static/resources/images/platform-bg.png -------------------------------------------------------------------------------- /petclinic/src/main/resources/static/resources/images/spring-logo-dataflow-mobile.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dsyer/spring-boot-startup-bench/c68adbcb4ab70005d8a056c34ea42e0b1f7ab810/petclinic/src/main/resources/static/resources/images/spring-logo-dataflow-mobile.png -------------------------------------------------------------------------------- /petclinic/src/main/resources/static/resources/images/spring-logo-dataflow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dsyer/spring-boot-startup-bench/c68adbcb4ab70005d8a056c34ea42e0b1f7ab810/petclinic/src/main/resources/static/resources/images/spring-logo-dataflow.png -------------------------------------------------------------------------------- /petclinic/src/main/resources/static/resources/images/spring-pivotal-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dsyer/spring-boot-startup-bench/c68adbcb4ab70005d8a056c34ea42e0b1f7ab810/petclinic/src/main/resources/static/resources/images/spring-pivotal-logo.png -------------------------------------------------------------------------------- /petclinic/src/main/resources/templates/error.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

Something happened...

8 |

Exception message

9 | 10 | 11 | -------------------------------------------------------------------------------- /petclinic/src/main/resources/templates/fragments/inputField.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 |
8 | 9 |
10 | 12 | 15 | 16 | 19 | Error 20 | 21 |
22 |
23 |
24 |
25 | 26 | 27 | -------------------------------------------------------------------------------- /petclinic/src/main/resources/templates/fragments/selectField.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 |
8 | 9 | 10 |
11 | 15 | 18 | 19 | 22 | Error 23 | 24 |
25 |
26 |
27 |
28 | 29 | -------------------------------------------------------------------------------- /petclinic/src/main/resources/templates/owners/createOrUpdateOwnerForm.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 |

Owner

7 |
8 |
9 | 11 | 13 | 15 | 17 | 19 |
20 |
21 |
22 | 26 |
27 |
28 |
29 | 30 | 31 | -------------------------------------------------------------------------------- /petclinic/src/main/resources/templates/owners/findOwners.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 |

Find Owners

7 | 8 |
10 |
11 |
12 | 13 |
14 |
17 |

Error

18 |
19 |
20 |
21 |
22 |
23 |
24 | 26 |
27 |
28 | 29 |
30 | 31 |
32 | Add Owner 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /petclinic/src/main/resources/templates/owners/ownerDetails.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | 8 | 9 |

Owner Information

10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 |
Name
Address
City
Telephone
30 | 31 | Edit 32 | Owner 33 | Add 34 | New Pet 35 | 36 |
37 |
38 |
39 |

Pets and Visits

40 | 41 | 42 | 43 | 44 | 55 | 77 | 78 | 79 |
45 |
46 |
Name
47 |
48 |
Birth Date
49 |
51 |
Type
52 |
53 |
54 |
56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 71 | 74 | 75 |
Visit DateDescription
Edit 70 | PetAdd 73 | Visit
76 |
80 | 81 | 82 | 83 | -------------------------------------------------------------------------------- /petclinic/src/main/resources/templates/owners/ownersList.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

Owners

8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 24 | 28 | 29 | 30 |
NameAddressCityTelephonePets
22 | 23 | 25 | 26 | 27 |
31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /petclinic/src/main/resources/templates/pets/createOrUpdatePetForm.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 |

7 | New 8 | Pet 9 |

10 |
11 | 12 |
13 |
14 | 15 |
16 | 17 |
18 |
19 | 21 | 23 | 25 |
26 |
27 |
28 | 32 |
33 |
34 |
35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /petclinic/src/main/resources/templates/pets/createOrUpdateVisitForm.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 |

7 | New 8 | Visit 9 |

10 | 11 | Pet 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 25 | 26 | 28 | 29 |
NameBirth DateTypeOwner
30 | 31 |
32 |
33 | 35 | 37 |
38 | 39 |
40 |
41 | 42 | 43 |
44 |
45 |
46 | 47 |
48 | Previous Visits 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 |
DateDescription
59 | 60 | 61 | -------------------------------------------------------------------------------- /petclinic/src/main/resources/templates/vets/vetList.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | 8 |

Veterinarians

9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 23 | 24 | 25 |
NameSpecialties
none
26 | 27 | 28 | 29 | 31 | 32 | 33 |
View 30 | as XMLView as JSON
34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /petclinic/src/main/resources/templates/welcome.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

Welcome

8 |
9 |
10 | 11 |
12 |
13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /petclinic/src/main/wro/wro.properties: -------------------------------------------------------------------------------- 1 | #List of preProcessors 2 | preProcessors=lessCssImport 3 | #List of postProcessors 4 | postProcessors=less4j -------------------------------------------------------------------------------- /petclinic/src/main/wro/wro.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | classpath:META-INF/resources/webjars/bootstrap/3.3.6/less/bootstrap.less 4 | /petclinic.less 5 | 6 | 7 | -------------------------------------------------------------------------------- /petclinic/src/test/java/org/springframework/samples/petclinic/model/ValidatorTests.java: -------------------------------------------------------------------------------- 1 | package org.springframework.samples.petclinic.model; 2 | 3 | import static org.assertj.core.api.Assertions.assertThat; 4 | 5 | import java.util.Locale; 6 | import java.util.Set; 7 | 8 | import javax.validation.ConstraintViolation; 9 | import javax.validation.Validator; 10 | 11 | import org.junit.Test; 12 | import org.springframework.context.i18n.LocaleContextHolder; 13 | import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean; 14 | 15 | /** 16 | * @author Michael Isvy 17 | * Simple test to make sure that Bean Validation is working 18 | * (useful when upgrading to a new version of Hibernate Validator/ Bean Validation) 19 | */ 20 | public class ValidatorTests { 21 | 22 | private Validator createValidator() { 23 | LocalValidatorFactoryBean localValidatorFactoryBean = new LocalValidatorFactoryBean(); 24 | localValidatorFactoryBean.afterPropertiesSet(); 25 | return localValidatorFactoryBean; 26 | } 27 | 28 | @Test 29 | public void shouldNotValidateWhenFirstNameEmpty() { 30 | 31 | LocaleContextHolder.setLocale(Locale.ENGLISH); 32 | Person person = new Person(); 33 | person.setFirstName(""); 34 | person.setLastName("smith"); 35 | 36 | Validator validator = createValidator(); 37 | Set> constraintViolations = validator.validate(person); 38 | 39 | assertThat(constraintViolations.size()).isEqualTo(1); 40 | ConstraintViolation violation = constraintViolations.iterator().next(); 41 | assertThat(violation.getPropertyPath().toString()).isEqualTo("firstName"); 42 | assertThat(violation.getMessage()).isEqualTo("may not be empty"); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /petclinic/src/test/java/org/springframework/samples/petclinic/service/EntityUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2013 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.samples.petclinic.service; 18 | 19 | import java.util.Collection; 20 | 21 | import org.springframework.orm.ObjectRetrievalFailureException; 22 | import org.springframework.samples.petclinic.model.BaseEntity; 23 | 24 | /** 25 | * Utility methods for handling entities. Separate from the BaseEntity class mainly because of dependency on the 26 | * ORM-associated ObjectRetrievalFailureException. 27 | * 28 | * @author Juergen Hoeller 29 | * @author Sam Brannen 30 | * @see org.springframework.samples.petclinic.model.BaseEntity 31 | * @since 29.10.2003 32 | */ 33 | public abstract class EntityUtils { 34 | 35 | /** 36 | * Look up the entity of the given class with the given id in the given collection. 37 | * 38 | * @param entities the collection to search 39 | * @param entityClass the entity class to look up 40 | * @param entityId the entity id to look up 41 | * @return the found entity 42 | * @throws ObjectRetrievalFailureException if the entity was not found 43 | */ 44 | public static T getById(Collection entities, Class entityClass, int entityId) 45 | throws ObjectRetrievalFailureException { 46 | for (T entity : entities) { 47 | if (entity.getId() == entityId && entityClass.isInstance(entity)) { 48 | return entity; 49 | } 50 | } 51 | throw new ObjectRetrievalFailureException(entityClass, entityId); 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /petclinic/src/test/java/org/springframework/samples/petclinic/system/CrashControllerTests.java: -------------------------------------------------------------------------------- 1 | package org.springframework.samples.petclinic.system; 2 | 3 | import org.junit.Before; 4 | import org.junit.Ignore; 5 | import org.junit.Test; 6 | import org.junit.runner.RunWith; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.boot.test.context.SpringBootTest; 9 | import org.springframework.samples.petclinic.PetClinicApplication; 10 | import org.springframework.samples.petclinic.system.CrashController; 11 | import org.springframework.test.context.junit4.SpringRunner; 12 | import org.springframework.test.context.web.WebAppConfiguration; 13 | import org.springframework.test.web.servlet.MockMvc; 14 | import org.springframework.test.web.servlet.setup.MockMvcBuilders; 15 | 16 | import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; 17 | import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; 18 | 19 | /** 20 | * Test class for {@link CrashController} 21 | * 22 | * @author Colin But 23 | */ 24 | @RunWith(SpringRunner.class) 25 | @SpringBootTest(classes = PetClinicApplication.class) 26 | @WebAppConfiguration 27 | // Waiting https://github.com/spring-projects/spring-boot/issues/5574 28 | @Ignore 29 | public class CrashControllerTests { 30 | 31 | @Autowired 32 | private CrashController crashController; 33 | 34 | private MockMvc mockMvc; 35 | 36 | @Before 37 | public void setup() { 38 | this.mockMvc = MockMvcBuilders 39 | .standaloneSetup(crashController) 40 | //.setHandlerExceptionResolvers(new SimpleMappingExceptionResolver()) 41 | .build(); 42 | } 43 | 44 | @Test 45 | public void testTriggerException() throws Exception { 46 | mockMvc.perform(get("/oups")) 47 | .andExpect(view().name("exception")) 48 | .andExpect(model().attributeExists("exception")) 49 | .andExpect(forwardedUrl("exception")) 50 | .andExpect(status().isOk()); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 1.5.3.RELEASE 9 | 10 | 11 | com.example 12 | parent-demo 13 | 0.0.1-SNAPSHOT 14 | pom 15 | Parent Demo 16 | 17 | 18 | configserver 19 | demo 20 | minimal 21 | petclinic 22 | petclinic-latest 23 | alt 24 | benchmarks 25 | static 26 | flux 27 | mvc 28 | launcher 29 | 30 | 31 | 32 | 1.8 33 | 34 | 35 | 36 | 37 | spring-libs-snapshot 38 | http://repo.spring.io/libs-snapshot 39 | 40 | true 41 | 42 | 43 | true 44 | 45 | 46 | 47 | 48 | 49 | 50 | spring-libs-snapshot 51 | http://repo.spring.io/libs-snapshot 52 | 53 | true 54 | 55 | 56 | true 57 | 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /s1p.txt: -------------------------------------------------------------------------------- 1 | # How Fast is Spring? 2 | 3 | In this presentation we take stock of some of the myths and assumptions regarding the runtime costs of using Spring. The conclusion is that preconceptions about slowness, component scanning, autoconfiguration, binding, use of reflection are all completely wrong. We look at data from a large set of benchmarks, analysing the performance of Spring applications. We concentrate on JVM startup time, but data are also available regarding total resource usage, and other runtime overheads. Spring is not slow, despite many people's preconceptions, but measuring the performance can bring useful optimizations, some of which we will point out in this session. Finally, we can go deeper than that and show what kinds of apps are slower to start and why. 4 | -------------------------------------------------------------------------------- /static/src/main/java/com/example/config/ApplicationBuilder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.example.config; 17 | 18 | import org.springframework.beans.BeanUtils; 19 | import org.springframework.boot.builder.SpringApplicationBuilder; 20 | import org.springframework.util.ClassUtils; 21 | 22 | /** 23 | * @author Dave Syer 24 | * 25 | */ 26 | public class ApplicationBuilder { 27 | 28 | public static SpringApplicationBuilder builder(Class type) { 29 | // Defensive reflective builder to work with Boot 1.5 and 2.0 30 | if (ClassUtils.hasConstructor(SpringApplicationBuilder.class, Class[].class)) { 31 | return BeanUtils 32 | .instantiateClass( 33 | ClassUtils.getConstructorIfAvailable( 34 | SpringApplicationBuilder.class, Class[].class), 35 | (Object) new Class[] { type }); 36 | } 37 | return BeanUtils 38 | .instantiateClass( 39 | ClassUtils.getConstructorIfAvailable( 40 | SpringApplicationBuilder.class, Object[].class), 41 | (Object) new Object[] { type.getName() }); 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /static/src/main/java/com/example/demo/DemoApplication.java: -------------------------------------------------------------------------------- 1 | package com.example.demo; 2 | 3 | import com.example.config.ApplicationBuilder; 4 | 5 | import org.springframework.boot.CommandLineRunner; 6 | import org.springframework.boot.autoconfigure.SpringBootApplication; 7 | import org.springframework.boot.autoconfigure.condition.ConditionalOnNotWebApplication; 8 | import org.springframework.context.annotation.Bean; 9 | import org.springframework.web.bind.annotation.GetMapping; 10 | import org.springframework.web.bind.annotation.RestController; 11 | 12 | @SpringBootApplication 13 | @RestController 14 | public class DemoApplication { 15 | 16 | @GetMapping("/") 17 | public String home() { 18 | return "Hello"; 19 | } 20 | 21 | public static void main(String[] args) throws Exception { 22 | ApplicationBuilder.builder(DemoApplication.class).run(args); 23 | } 24 | 25 | @Bean 26 | @ConditionalOnNotWebApplication 27 | public CommandLineRunner runner() { 28 | return args -> { 29 | Thread t = new Thread(() -> { 30 | while (true) { 31 | try { 32 | Thread.sleep(100L); 33 | } 34 | catch (InterruptedException e) { 35 | Thread.currentThread().interrupt(); 36 | } 37 | } 38 | }); 39 | t.setDaemon(false); 40 | t.start(); 41 | }; 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /static/src/main/java/com/example/jpa/JpaApplication.java: -------------------------------------------------------------------------------- 1 | package com.example.jpa; 2 | 3 | import java.util.UUID; 4 | 5 | import javax.persistence.Entity; 6 | import javax.persistence.Id; 7 | 8 | import com.example.config.ApplicationBuilder; 9 | 10 | import org.springframework.boot.autoconfigure.SpringBootApplication; 11 | import org.springframework.data.jpa.repository.JpaRepository; 12 | import org.springframework.web.bind.annotation.GetMapping; 13 | import org.springframework.web.bind.annotation.RestController; 14 | 15 | @SpringBootApplication 16 | @RestController 17 | public class JpaApplication { 18 | 19 | @GetMapping("/") 20 | public String home() { 21 | return "Hello"; 22 | } 23 | 24 | public static void main(String[] args) throws Exception { 25 | ApplicationBuilder.builder(JpaApplication.class).run(args); 26 | } 27 | 28 | } 29 | 30 | interface GreetingRepository extends JpaRepository { 31 | } 32 | 33 | @Entity 34 | class Greeting { 35 | 36 | @Id 37 | private String id = UUID.randomUUID().toString(); 38 | 39 | private String msg; 40 | 41 | @SuppressWarnings("unused") 42 | private Greeting() { 43 | } 44 | 45 | public Greeting(String msg) { 46 | this.msg = msg; 47 | } 48 | 49 | public String getId() { 50 | return id; 51 | } 52 | 53 | public String getMsg() { 54 | return msg; 55 | } 56 | 57 | public void setMsg(String msg) { 58 | this.msg = msg; 59 | } 60 | 61 | @Override 62 | public String toString() { 63 | return "Greeting [msg=" + msg + "]"; 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /static/src/main/java/com/example/thin/ThinApplication.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.example.thin; 18 | 19 | import com.example.config.ApplicationBuilder; 20 | 21 | import org.springframework.boot.SpringBootConfiguration; 22 | import org.springframework.boot.autoconfigure.http.HttpMessageConvertersAutoConfiguration; 23 | import org.springframework.boot.autoconfigure.web.servlet.DispatcherServletAutoConfiguration; 24 | import org.springframework.boot.autoconfigure.web.servlet.ServletWebServerFactoryAutoConfiguration; 25 | import org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration; 26 | import org.springframework.context.annotation.Import; 27 | import org.springframework.web.bind.annotation.GetMapping; 28 | import org.springframework.web.bind.annotation.RestController; 29 | 30 | @SpringBootConfiguration 31 | @Import({ HttpMessageConvertersAutoConfiguration.class, 32 | DispatcherServletAutoConfiguration.class, 33 | ServletWebServerFactoryAutoConfiguration.class, WebMvcAutoConfiguration.class }) 34 | @RestController 35 | public class ThinApplication { 36 | 37 | @GetMapping("/") 38 | public String home() { 39 | return "Hello"; 40 | } 41 | 42 | public static void main(String[] args) { 43 | ApplicationBuilder.builder(ThinApplication.class).run(args); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /static/src/main/resources/META-INF/spring.factories: -------------------------------------------------------------------------------- 1 | org.springframework.context.ApplicationListener=\ 2 | com.example.config.BeanCountingApplicationListener,\ 3 | com.example.config.StartupApplicationListener,\ 4 | com.example.config.ShutdownApplicationListener 5 | -------------------------------------------------------------------------------- /static/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | # logging.level.org.springframework=DEBUG 2 | # logging.level.com.example=DEBUG 3 | # logging.level.org.springframework.beans.factory.support=DEBUG 4 | #management.security.enabled=false 5 | -------------------------------------------------------------------------------- /static/src/main/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /static/src/test/java/com/example/bench/DevToolsLauncherState.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */package com.example.bench; 16 | 17 | import java.io.File; 18 | import java.nio.file.Files; 19 | import java.nio.file.Path; 20 | import java.util.Date; 21 | import java.util.stream.Collectors; 22 | import java.util.stream.IntStream; 23 | 24 | public class DevToolsLauncherState extends ProcessLauncherState { 25 | 26 | private static String[] defaultArgs = new String[] { "--server.port=0", 27 | "--spring.devtools.livereload.enabled=false", 28 | "--spring.devtools.restart.pollInterval=10", 29 | "--spring.devtools.restart.quietPeriod=1", "--spring.jmx.enabled=false" }; 30 | 31 | private Path restart; 32 | private int count = 0; 33 | 34 | public DevToolsLauncherState(String dir, String restart, String... args) { 35 | super(dir, enhance(args)); 36 | this.restart = new File(dir, restart).toPath(); 37 | } 38 | 39 | private static String[] enhance(String[] args) { 40 | String[] result = new String[args.length + defaultArgs.length]; 41 | System.arraycopy(defaultArgs, 0, result, 0, defaultArgs.length); 42 | if (args.length > 0) { 43 | System.arraycopy(args, 0, result, defaultArgs.length, args.length); 44 | } 45 | return result; 46 | } 47 | 48 | @Override 49 | public void before() throws Exception { 50 | super.before(); 51 | super.run(); 52 | } 53 | 54 | @Override 55 | public void run() throws Exception { 56 | monitor(); 57 | } 58 | 59 | public void update() throws Exception { 60 | drain(); 61 | Files.write(restart, (new Date().toString() + IntStream.range(0, count++) 62 | .mapToObj(i -> "" + i).collect(Collectors.joining(","))).getBytes()); 63 | finish(); 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /static/src/test/java/com/example/bench/ProcessLauncherStateTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.example.bench; 18 | 19 | import com.example.bench.CaptureSystemOutput.OutputCapture; 20 | import com.example.bench.CdsBenchmark.CdsState; 21 | import com.example.bench.StripBenchmark.ApplicationState; 22 | import org.junit.jupiter.api.Test; 23 | 24 | import static org.assertj.core.api.Assertions.assertThat; 25 | 26 | /** 27 | * @author Dave Syer 28 | * 29 | */ 30 | public class ProcessLauncherStateTests { 31 | 32 | @Test 33 | @CaptureSystemOutput 34 | public void vanilla(OutputCapture output) throws Exception { 35 | // System.setProperty("bench.args", "-verbose:class"); 36 | ProcessLauncherState state = new ProcessLauncherState("target", 37 | "--server.port=0"); 38 | state.setProfiles("jlog"); 39 | state.before(); 40 | state.run(); 41 | state.after(); 42 | assertThat(output.toString()).contains("Benchmark app started"); 43 | } 44 | 45 | @Test 46 | @CaptureSystemOutput 47 | public void func(OutputCapture output) throws Exception { 48 | ApplicationState state = new ApplicationState(); 49 | state.sample = ApplicationState.Sample.func; 50 | state.addArgs("-Ddebug=true"); 51 | state.start(); 52 | state.run(); 53 | state.after(); 54 | assertThat(output.toString()).contains("FuncApplication"); 55 | assertThat(output.toString()).contains("Benchmark app started"); 56 | } 57 | 58 | @Test 59 | @CaptureSystemOutput 60 | public void cds(OutputCapture output) throws Exception { 61 | CdsState state = new CdsState(); 62 | state.sample = CdsState.Sample.demo; 63 | state.addArgs("-Ddebug=true"); 64 | state.start(); 65 | state.run(); 66 | state.after(); 67 | assertThat(output.toString()).contains("DemoApplication"); 68 | assertThat(output.toString()).contains("Benchmark app started"); 69 | } 70 | 71 | } 72 | -------------------------------------------------------------------------------- /static/src/test/java/com/example/demo/CustomConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.example.demo; 18 | 19 | import com.netflix.zuul.ZuulFilter; 20 | 21 | import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; 22 | import org.springframework.cloud.netflix.zuul.EnableZuulProxy; 23 | import org.springframework.context.annotation.Configuration; 24 | 25 | /** 26 | * @author Dave Syer 27 | * 28 | */ 29 | @Configuration 30 | public class CustomConfiguration { 31 | 32 | @Configuration 33 | @ConditionalOnClass(ZuulFilter.class) 34 | @EnableZuulProxy 35 | public static class ZuulConfiguration { 36 | 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /static/src/test/java/com/example/demo/DemoApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.example.demo; 2 | 3 | import org.junit.jupiter.api.Test; 4 | 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.annotation.DirtiesContext; 7 | 8 | @SpringBootTest 9 | @DirtiesContext 10 | public class DemoApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() throws Exception { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /static/src/test/java/com/example/func/FuncApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.example.func; 2 | 3 | import java.net.URI; 4 | 5 | import org.junit.jupiter.api.Test; 6 | 7 | import org.springframework.boot.builder.SpringApplicationBuilder; 8 | import org.springframework.boot.test.web.client.TestRestTemplate; 9 | import org.springframework.context.ConfigurableApplicationContext; 10 | import org.springframework.http.HttpStatus; 11 | import org.springframework.http.ResponseEntity; 12 | import org.springframework.util.SocketUtils; 13 | 14 | import static org.assertj.core.api.Assertions.assertThat; 15 | 16 | public class FuncApplicationTests { 17 | 18 | private TestRestTemplate rest = new TestRestTemplate(); 19 | 20 | @Test 21 | public void contextLoads() throws Exception { 22 | int port = SocketUtils.findAvailableTcpPort(); 23 | ConfigurableApplicationContext context = new SpringApplicationBuilder( 24 | FuncApplication.class).initializers(new WebAppInitializer()) 25 | .run("--server.port=" + port); 26 | ResponseEntity result = rest 27 | .getForEntity(new URI("http://localhost:" + port + "/"), String.class); 28 | assertThat(result.getStatusCode()).isEqualTo(HttpStatus.OK); 29 | context.close(); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /static/src/test/java/com/example/lite/LiteApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.example.lite; 2 | 3 | import java.net.URI; 4 | 5 | import org.junit.jupiter.api.Test; 6 | 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.boot.test.context.SpringBootTest; 9 | import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; 10 | import org.springframework.boot.test.web.client.TestRestTemplate; 11 | import org.springframework.http.HttpStatus; 12 | import org.springframework.http.ResponseEntity; 13 | import org.springframework.test.annotation.DirtiesContext; 14 | import org.springframework.test.context.ContextConfiguration; 15 | 16 | import static org.assertj.core.api.Assertions.assertThat; 17 | 18 | @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) 19 | @ContextConfiguration(classes = LiteApplication.class) 20 | @DirtiesContext 21 | public class LiteApplicationTests { 22 | 23 | @Autowired 24 | private TestRestTemplate rest; 25 | 26 | @Test 27 | public void contextLoads() throws Exception { 28 | ResponseEntity result = rest.getForEntity(new URI("/"), String.class); 29 | assertThat(result.getStatusCode()).isEqualTo(HttpStatus.OK); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /static/src/test/java/com/example/thin/ThinApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.example.thin; 2 | 3 | import java.net.URI; 4 | 5 | import org.junit.jupiter.api.Test; 6 | 7 | import org.springframework.boot.test.context.SpringBootTest; 8 | import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; 9 | import org.springframework.boot.test.web.client.TestRestTemplate; 10 | import org.springframework.boot.web.server.LocalServerPort; 11 | import org.springframework.http.HttpStatus; 12 | import org.springframework.http.ResponseEntity; 13 | import org.springframework.test.annotation.DirtiesContext; 14 | import org.springframework.test.context.ContextConfiguration; 15 | 16 | import static org.assertj.core.api.Assertions.assertThat; 17 | 18 | @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) 19 | @ContextConfiguration(classes = ThinApplication.class) 20 | @DirtiesContext 21 | public class ThinApplicationTests { 22 | 23 | @LocalServerPort 24 | private int port; 25 | 26 | private TestRestTemplate rest = new TestRestTemplate(); 27 | 28 | @Test 29 | public void contextLoads() throws Exception { 30 | ResponseEntity result = rest 31 | .getForEntity(new URI("http://localhost:" + port + "/"), String.class); 32 | assertThat(result.getStatusCode()).isEqualTo(HttpStatus.OK); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /static/src/test/resources/META-INF/services/jmh.mbr.core.ResultsWriterFactory: -------------------------------------------------------------------------------- 1 | com.example.bench.CsvResultsWriterFactory -------------------------------------------------------------------------------- /static/src/test/resources/META-INF/thin-actj.properties: -------------------------------------------------------------------------------- 1 | dependencies.spring-boot-starter-actuator=org.springframework.boot:spring-boot-starter-actuator 2 | dependencies.spring-boot-starter-web=org.springframework.boot:spring-boot-starter-web 3 | dependencies.spring-boot-starter-jdbc=org.springframework.boot:spring-boot-starter-jdbc 4 | dependencies.h2=com.h2database:h2 5 | -------------------------------------------------------------------------------- /static/src/test/resources/META-INF/thin-actr.properties: -------------------------------------------------------------------------------- 1 | dependencies.spring-boot-starter-web=org.springframework.boot:spring-boot-starter-web 2 | dependencies.spring-boot-starter-actuator=org.springframework.boot:spring-boot-starter-actuator 3 | -------------------------------------------------------------------------------- /static/src/test/resources/META-INF/thin-buna.properties: -------------------------------------------------------------------------------- 1 | dependencies.spring-boot-starter-web=org.springframework.boot:spring-boot-starter-web 2 | exclusions.spring-boot-starter-actuator=org.springframework.boot:spring-boot-actuator 3 | dependencies.spring-cloud-starter-bus=org.springframework.cloud:spring-cloud-starter-bus-amqp 4 | -------------------------------------------------------------------------------- /static/src/test/resources/META-INF/thin-busr.properties: -------------------------------------------------------------------------------- 1 | dependencies.spring-boot-starter-web=org.springframework.boot:spring-boot-starter-web 2 | dependencies.spring-boot-starter-actuator=org.springframework.boot:spring-boot-starter-actuator 3 | dependencies.spring-cloud-starter-bus=org.springframework.cloud:spring-cloud-starter-bus-amqp 4 | -------------------------------------------------------------------------------- /static/src/test/resources/META-INF/thin-conf.properties: -------------------------------------------------------------------------------- 1 | dependencies.spring-boot-starter-web=org.springframework.boot:spring-boot-starter-web 2 | dependencies.spring-boot-starter-actuator=org.springframework.boot:spring-boot-starter-actuator 3 | dependencies.spring-cloud-starter-config=org.springframework.cloud:spring-cloud-starter-config 4 | -------------------------------------------------------------------------------- /static/src/test/resources/META-INF/thin-devtools.properties: -------------------------------------------------------------------------------- 1 | dependencies.spring-boot-devtools=org.springframework.boot:spring-boot-devtools 2 | -------------------------------------------------------------------------------- /static/src/test/resources/META-INF/thin-empt.properties: -------------------------------------------------------------------------------- 1 | dependencies.spring-boot-starter-web=org.springframework.boot:spring-boot-starter 2 | -------------------------------------------------------------------------------- /static/src/test/resources/META-INF/thin-erka.properties: -------------------------------------------------------------------------------- 1 | dependencies.spring-boot-starter-web=org.springframework.boot:spring-boot-starter-web 2 | dependencies.spring-boot-starter-actuator=org.springframework.boot:spring-boot-starter-actuator 3 | dependencies.spring-cloud-starter-eureka=org.springframework.cloud:spring-cloud-starter-netflix-eureka-client 4 | -------------------------------------------------------------------------------- /static/src/test/resources/META-INF/thin-erkb.properties: -------------------------------------------------------------------------------- 1 | dependencies.spring-boot-starter-web=org.springframework.boot:spring-boot-starter-web 2 | dependencies.spring-boot-starter-actuator=org.springframework.boot:spring-boot-starter-actuator 3 | dependencies.spring-cloud-starter-eureka=org.springframework.cloud:spring-cloud-starter-netflix-eureka-client 4 | dependencies.spring-cloud-starter-bus=org.springframework.cloud:spring-cloud-starter-bus-amqp 5 | -------------------------------------------------------------------------------- /static/src/test/resources/META-INF/thin-flux.properties: -------------------------------------------------------------------------------- 1 | dependencies.spring-boot-starter-web=org.springframework.boot:spring-boot-starter-webflux 2 | -------------------------------------------------------------------------------- /static/src/test/resources/META-INF/thin-jdbc.properties: -------------------------------------------------------------------------------- 1 | dependencies.spring-boot-starter-web=org.springframework.boot:spring-boot-starter-web 2 | dependencies.spring-boot-starter-jdbc=org.springframework.boot:spring-boot-starter-jdbc 3 | dependencies.h2=com.h2database:h2 4 | -------------------------------------------------------------------------------- /static/src/test/resources/META-INF/thin-jlog.properties: -------------------------------------------------------------------------------- 1 | exclusions.spring-boot-starter-logging=org.springframework.boot:spring-boot-starter-logging 2 | exclusions.spring-boot-starter-json=org.springframework.boot:spring-boot-starter-json 3 | exclusions.jackson-databind=com.fasterxml.jackson.core:jackson-databind 4 | exclusions.hibernate-validator=org.hibernate.validator:hibernate-validator 5 | exclusions.old-hibernate-validator=org.hibernate:hibernate-validator 6 | dependencies.slf4j-jdk14=org.slf4j:slf4j-jdk14 -------------------------------------------------------------------------------- /static/src/test/resources/META-INF/thin-jpae.properties: -------------------------------------------------------------------------------- 1 | dependencies.spring-boot-starter-web=org.springframework.boot:spring-boot-starter-web 2 | dependencies.spring-boot-starter-data-jpa=org.springframework.boot:spring-boot-starter-data-jpa 3 | dependencies.h2=com.h2database:h2 4 | -------------------------------------------------------------------------------- /static/src/test/resources/META-INF/thin-slth.properties: -------------------------------------------------------------------------------- 1 | dependencies.spring-boot-starter-web=org.springframework.boot:spring-boot-starter-web 2 | dependencies.spring-boot-starter-actuator=org.springframework.boot:spring-boot-starter-actuator 3 | dependencies.spring-cloud-starter-bus=org.springframework.cloud:spring-cloud-starter-bus-amqp 4 | dependencies.spring-cloud-starter-sleuth=org.springframework.cloud:spring-cloud-starter-sleuth 5 | -------------------------------------------------------------------------------- /static/src/test/resources/META-INF/thin-zuul.properties: -------------------------------------------------------------------------------- 1 | dependencies.spring-boot-starter-web=org.springframework.boot:spring-boot-starter-web 2 | dependencies.spring-boot-starter-actuator=org.springframework.boot:spring-boot-starter-actuator 3 | dependencies.spring-cloud-starter-bus=org.springframework.cloud:spring-cloud-starter-bus-amqp 4 | dependencies.spring-cloud-starter-zuul=org.springframework.cloud:spring-cloud-starter-netflix-zuul 5 | -------------------------------------------------------------------------------- /static/src/test/resources/META-INF/thin.properties: -------------------------------------------------------------------------------- 1 | dependencies.spring-boot-starter-web=org.springframework.boot:spring-boot-starter-web 2 | exclusions.jmh-core=org.openjdk.jmh:jmh-core 3 | exclusions.spring-boot-thin-launcher=org.springframework.boot.experimental:spring-boot-thin-launcher 4 | exclusions.log4j-to-slf4j=org.apache.logging.log4j:log4j-to-slf4j 5 | exclusions.tools=com.sun:tools -------------------------------------------------------------------------------- /vagrant/Vagrantfile: -------------------------------------------------------------------------------- 1 | Vagrant.configure("2") do |config| 2 | config.vm.synced_folder "..", "/build" 3 | config.vm.provider :docker do |d| 4 | config.vm.box = nil 5 | d.image = "frolvlad/alpine-oraclejdk8:slim" 6 | end 7 | config.vm.provider :aws do |aws,override| 8 | config.vm.box = "dummy" 9 | aws.access_key_id = ENV['AWS_ACCESS_KEY'] 10 | aws.secret_access_key = ENV['AWS_SECRET_KEY'] 11 | aws.keypair_name = ENV['AWS_KEYPAIR'] 12 | aws.security_groups = ["vagrant"] 13 | aws.ami = "ami-153e6470" 14 | aws.region = "us-east-2" 15 | aws.instance_type = "t2.large" 16 | override.ssh.username = "ubuntu" 17 | override.ssh.private_key_path = "~/.ssh/id_rsa.#{ENV['AWS_KEYPAIR']}" 18 | end 19 | config.vm.provision "shell", inline: <<-SHELL 20 | apt-get update 21 | apt-get install -y openjdk-8-jdk 22 | SHELL 23 | end 24 | --------------------------------------------------------------------------------