diff --git a/docs/images/spring-petclinic-1.png b/docs/images/spring-petclinic-1.png index 551a640c..fc3864bd 100644 Binary files a/docs/images/spring-petclinic-1.png and b/docs/images/spring-petclinic-1.png differ diff --git a/docs/spring-petclinic.md b/docs/spring-petclinic.md index bbb773a7..c512a488 100644 --- a/docs/spring-petclinic.md +++ b/docs/spring-petclinic.md @@ -1,6 +1,6 @@ # The Spring PetClinic example -This is a step-by-step guide to recreating the [Spring PetClinic example diagrams](https://structurizr.com/public/1). It assumes that you have working Java, Maven and git installations plus a development environment to write code. +This is a step-by-step guide to recreating the [Spring PetClinic example diagrams](https://structurizr.com/public/1). It assumes that you have working Java, Maven and git installations plus a development environment to write code. The full source code for this example can be found in the [SpringPetClinic.java file](https://github.com/structurizr/java/blob/master/structurizr-examples/src/com/structurizr/example/spring/petclinic/SpringPetClinic.java). ## 1. Clone and build the Spring PetClinic code @@ -134,7 +134,7 @@ componentView.addAllPeople(); componentView.add(relationalDatabase); ``` -## 7. Link the components to the source code +## 7. Linking elements to external resources In order to create a set of maps for the Spring PetClinic system that reflect reality, we can link the components on the component diagram to the source code. This isn't necessary, but doing so means that we can [navigate from the diagrams to the code](https://structurizr.com/help/diagram-navigation). @@ -151,6 +151,12 @@ for (Component component : webApplication.getComponents()) { } ``` +Since we don't have a component model for the database, let's instead simply link the database element to the data definition language in GitHub. + +```java +relationalDatabase.setUrl("https://github.com/spring-projects/spring-petclinic/tree/master/src/main/resources/db/hsqldb"); +``` + ## 8. Styling the diagrams By default, Structurizr will render all of the elements as grey boxes. However, the elements and relationships can be styled. @@ -194,8 +200,6 @@ target/spring-petclinic-1.0.0-SNAPSHOT/WEB-INF/lib ## 10. View the diagrams and layout the elements -If you sign in to Structurizr and open the workspace you just uploaded, you'll see something like this. +If you sign in to Structurizr and open the workspace you just uploaded, you'll see something like this. Structurizr doesn't do any automatic layout of the elements on your diagrams, so you will need to drag the boxes around to create a layout that you like. You can save the position of the diagram elements though. ![The Spring PetClinic workspace](images/spring-petclinic-1.png) - -Structurizr doesn't do any automatic layout of the elements on your diagrams, so you will need to drag the boxes around to create a layout that you like. You can save the position of the diagram elements though. And that's it! diff --git a/structurizr-examples/src/com/structurizr/example/spring/petclinic/SpringPetClinic.java b/structurizr-examples/src/com/structurizr/example/spring/petclinic/SpringPetClinic.java index 8f192dbf..d9428f00 100644 --- a/structurizr-examples/src/com/structurizr/example/spring/petclinic/SpringPetClinic.java +++ b/structurizr-examples/src/com/structurizr/example/spring/petclinic/SpringPetClinic.java @@ -97,6 +97,10 @@ public static void main(String[] args) throws Exception { } } + // rather than creating a component model for the database, let's simply link to the DDL + // (this is really just an example of linking an arbitrary element in the model to an external resource) + relationalDatabase.setUrl("https://github.com/spring-projects/spring-petclinic/tree/master/src/main/resources/db/hsqldb"); + // tag and style some elements springPetClinic.addTags("Spring PetClinic"); webApplication.getComponents().stream().filter(c -> c.getTechnology().equals(SpringComponentFinderStrategy.SPRING_MVC_CONTROLLER)).forEach(c -> c.addTags("Spring MVC Controller"));