Skip to content

Commit cdbac8f

Browse files
Updates to the Spring PetClinic example and docs.
1 parent bfe3476 commit cdbac8f

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

docs/images/spring-petclinic-1.png

-85.6 KB
Loading

docs/spring-petclinic.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# The Spring PetClinic example
22

3-
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.
3+
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).
44

55
## 1. Clone and build the Spring PetClinic code
66

@@ -134,7 +134,7 @@ componentView.addAllPeople();
134134
componentView.add(relationalDatabase);
135135
```
136136
137-
## 7. Link the components to the source code
137+
## 7. Linking elements to external resources
138138
139139
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).
140140

@@ -151,6 +151,12 @@ for (Component component : webApplication.getComponents()) {
151151
}
152152
```
153153

154+
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.
155+
156+
```java
157+
relationalDatabase.setUrl("https://github.com/spring-projects/spring-petclinic/tree/master/src/main/resources/db/hsqldb");
158+
```
159+
154160
## 8. Styling the diagrams
155161

156162
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
194200
195201
## 10. View the diagrams and layout the elements
196202
197-
If you sign in to Structurizr and open the workspace you just uploaded, you'll see something like this.
203+
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.
198204
199205
![The Spring PetClinic workspace](images/spring-petclinic-1.png)
200-
201-
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!

structurizr-examples/src/com/structurizr/example/spring/petclinic/SpringPetClinic.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,10 @@ public static void main(String[] args) throws Exception {
9797
}
9898
}
9999

100+
// rather than creating a component model for the database, let's simply link to the DDL
101+
// (this is really just an example of linking an arbitrary element in the model to an external resource)
102+
relationalDatabase.setUrl("https://github.com/spring-projects/spring-petclinic/tree/master/src/main/resources/db/hsqldb");
103+
100104
// tag and style some elements
101105
springPetClinic.addTags("Spring PetClinic");
102106
webApplication.getComponents().stream().filter(c -> c.getTechnology().equals(SpringComponentFinderStrategy.SPRING_MVC_CONTROLLER)).forEach(c -> c.addTags("Spring MVC Controller"));

0 commit comments

Comments
 (0)