|
| 1 | +# Converting the Spring application to a Quarkus one with compatibility libraries |
| 2 | + |
| 3 | +It is possible to recreate the application parts of the `quarkus3-spring-compatibility` project with a few steps. |
| 4 | +This is a great way of seeing that the Quarkus performance gains are because of the runtime, not the programming model or code of the application. |
| 5 | + |
| 6 | +## Doing the conversion for dev mode |
| 7 | + |
| 8 | +1. Save the `pom.xml`, which we don't want to write by hand: `cp quarkus3-spring-compatibility/pom.xml spring-pom.xml` |
| 9 | +2. Delete the compatibility project (we're about to recreate it from scratch!): `rm -rf quarkus3-spring-compatibility` |
| 10 | +3. Replace the spring pom: `mv spring-pom.xml springboot3/pom.xml` |
| 11 | +4. Delete the tests, which are hard to convert ([for now](https://github.com/orgs/quarkusio/projects/60)): `rm -rf springboot3/src/test` |
| 12 | +5. Start the app, with `(cd springboot3; quarkus dev)`. You'll see a failure and a crash. |
| 13 | +6. What's the problem? The `SpringBootApplication` class doesn't compile. The good news is it's not even needed with Quarkus. Delete it. |
| 14 | +7. Try `quarkus dev` again, and everything should work. Visiting the endpoint in a browser should work. |
| 15 | + |
| 16 | +## Prod mode and stress testing |
| 17 | + |
| 18 | +Although everything is working in dev mode, if you look at the `application.yml`, you can see it's filled with spring config. |
| 19 | +There's no Quarkus database configured. In dev mode, that's fine, because Quarkus auto-starts one as a dev service, but that won't work in prod mode. |
| 20 | +So we need to fill in config. |
| 21 | + |
| 22 | +1. Copy the Quarkus config over to the Spring app: `cp ./quarkus3/src/main/resources/application.yml ./springboot3/src/main/resources/application.yml` |
| 23 | +2. Build the app `(cd springboot3; ./mvnw clean package)` (don't forget the clean) |
| 24 | +3. Run the stress tests: `./scripts/stress.sh springboot3/target/quarkus-app/quarkus-run.jar` |
| 25 | + |
| 26 | +You should see that the throughput almost identical to the throughput of the 'normal' Quarkus app, and more than double that of the Quarkus-free Spring app. |
0 commit comments