Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Quarkus in 60 Minuten

Sponsored · Ship Features Fearlessly Turn features on and off without deploys. Used by thousands of Ruby developers.

Quarkus in 60 Minuten

Avatar for Dirk Weil

Dirk Weil

July 01, 2024
Tweet

More Decks by Dirk Weil

Other Decks in Technology

Transcript

  1. GEDOPLAN-Team GEDOPLAN GmbH, Bielefeld GEDOPLAN IT Consulting Consulting, Coaching, Konzepte,

    Reviews, Development GEDOPLAN IT Training Trainings in Berlin, Bielefeld, on-site Enterprise Java seit 1999 WildFly, Spring Boot, Quarkus … 2 gedoplan.de Quarkus in 60 Minuten
  2. Was ist Quarkus? Red Hats Antwort auf Spring Boot Cloud-native/Micro

    Services auf JEE-Basis (Standard!) Optimiert für kurze Startzeiten Hotspot und GraalVM https://quarkus.io/ Quarkus in 60 Minuten 3 gedoplan.de
  3. Project Bootstrap Core + Extensions (= Maven Dependencies) Project Bootstrap

    Maven/Gradle Plugin Quarkus CLI code.quarkus.io/ Quarkus in 60 Minuten 4 gedoplan.de mvn io.quarkus.platform:quarkus-maven-plugin:create <dependencies> <dependency> <groupId>io.quarkus</groupId> <artifactId>quarkus-resteasy-reactive</ar </dependency> <dependency> <groupId>io.quarkus</groupId> <artifactId>quarkus-junit5</artifactId> <scope>test</scope> </dependency> quarkus create app
  4. Running Quarkus application Prod mode Dev mode Quarkus in 60

    Minuten 5 gedoplan.de ❯ java -jar target/quarkus-app/quarkus-run.jar __ ____ __ _____ ___ __ ____ ______ --/ __ \/ / / / _ | / _ \/ //_/ / / / __/ -/ /_/ / /_/ / __ |/ , _/ ,< / /_/ /\ \ --\___\_\____/_/ |_/_/|_/_/|_|\____/___/ 2024-06-27 12:05:58,615 INFO [io.quarkus] (main) 60-min-quarkus 1.0-SNAPSHOT on JVM (po ❯ mvn quarkus:dev __ ____ __ _____ ___ __ ____ ______ --/ __ \/ / / / _ | / _ \/ //_/ / / / __/ -/ /_/ / /_/ / __ |/ , _/ ,< / /_/ /\ \ --\___\_\____/_/ |_/_/|_/_/|_|\____/___/ 2024-06-27 12:20:40,658 INFO [io.quarkus] (Quarkus Main Thread) 60-min-quarkus 1.0-SNAP 2024-06-27 12:20:40,663 INFO [io.quarkus] (Quarkus Main Thread) Profile dev activated. 2024-06-27 12:20:40,664 INFO [io.quarkus] (Quarkus Main Thread) Installed features: [cd -- Tests paused Press [e] to edit command line args (currently ''), [r] to resume testing, [o] Toggle te
  5. JPA (Jakarta/Java Persistence API), Hibernate Quarkus in 60 Minuten 6

    gedoplan.de <dependency> <groupId>io.quarkus</groupId> <artifactId>quarkus-hibernate-orm</artifactId> </dependency> @Entity public class Person { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Integer id; @ApplicationScoped public class PersonRepository { @Inject EntityManager entityManager; public List<Person> findAll() { return this.entityManager .createQuery("select x from Person x", Person.class) .getResultList(); }
  6. DB Extensions jdbc-db2, jdbc-derby, jdbc-h2, jdbc-mariadb, jdbc-mssql, jdbc-mysql, jdbc-oracle, jdbc-postgresql

    Dev services Quarkus in 60 Minuten 7 gedoplan.de <dependency> <groupId>io.quarkus</groupId> <artifactId>quarkus-jdbc-postgresql</artifactId> </dependency> ❯ mvn quarkus:dev 2024-06-27 12:20:38,188 INFO [io.qua.dat.dep.dev.DevServicesDatasourceProcessor] (buil Dev Services for default datasource (postgresql) started - container ID is 8419bcd27d91 __ ____ __ _____ ___ __ ____ ______ --/ __ \/ / / / _ | / _ \/ //_/ / / / __/ -/ /_/ / /_/ / __ |/ , _/ ,< / /_/ /\ \ --\___\_\____/_/ |_/_/|_/_/|_|\____/___/ 2024-06-27 12:20:40,658 INFO [io.quarkus] (Quarkus Main Thread) 60-min-quarkus 1.0-SNA
  7. Integration Tests, Continuous Testing Quarkus in 60 Minuten 8 gedoplan.de

    @QuarkusTest class GreetingResourceTest { @Test void testHelloEndpoint() { given() .when().get("/hello") .then() .statusCode(200) .body(is("Hello RESTEasy")); __ ____ __ _____ ___ __ ____ ______ --/ __ \/ / / / _ | / _ \/ //_/ / / / __/ -/ /_/ / /_/ / __ |/ , _/ ,< / /_/ /\ \ --\___\_\____/_/ |_/_/|_/_/|_|\____/___/ 2024-06-27 12:48:03,001 INFO [io.quarkus] (Quarkus Main Thread) 60-min-quarkus 1.0-S 2024-06-27 12:48:03,003 INFO [io.quarkus] (Quarkus Main Thread) Profile dev activate 2024-06-27 12:48:03,004 INFO [io.quarkus] (Quarkus Main Thread) Installed features: -- All 1 test is passing (0 skipped), 1 test was run in 7159ms. Tests completed at 13:05 Press [e] to edit command line args (currently ''), [r] to re-run, [o] Toggle test ou
  8. Native Mode Quarkus in 60 Minuten 9 gedoplan.de ❯ mvn

    package -Pnative -Dquarkus.native.container-build=true -DskipTests=true … =========================================================================================== GraalVM Native Image: Generating '60-min-quarkus-1.0-SNAPSHOT-runner' (executable)... =========================================================================================== … [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 03:57 min ❯ ./target/60-min-quarkus-1.0-SNAPSHOT-runner __ ____ __ _____ ___ __ ____ ______ --/ __ \/ / / / _ | / _ \/ //_/ / / / __/ -/ /_/ / /_/ / __ |/ , _/ ,< / /_/ /\ \ --\___\_\____/_/ |_/_/|_/_/|_|\____/___/ 2024-06-27 13:17:20,067 INFO [io.quarkus] (main) 60-min-quarkus 1.0-SNAPSHOT native (power started in 0.099s. Listening on: http://0.0.0.0:8080 2024-06-27 13:17:20,067 INFO [io.quarkus] (main) Profile prod activated. 2024-06-27 13:17:20,067 INFO [io.quarkus] (main) Installed features: [agroal, cdi, hiberna
  9. Quarkus vs. Spring Boot Es gibt ein Server-Framework auf Basis

    von JEE Beide Frameworks sind „auf Augenhöhe“ Spring hat größere Verbreitung Sehr großes Ökosystem (Quarkus < Spring - noch) Bessere Developer Experience bei Quarkus Footprint von Quarkus besser Bei JEE Knowledge liegt Quarkus näher Quarkus in 60 Minuten 11 gedoplan.de