JHipster is a rapid development platform that makes it easy to build modern JavaScript frontends backed by JVM microservices, including support for Micronaut. This allows you to produce microservice or monolith projects quickly, with plenty of customization options and a project structure that illustrates best practices when developing with Micronaut. As Micronaut is a JVM framework, it is compatible with Groovy, making it easy to use the Groovy language for tests (with Spock) and for general purpose application code, even within standard Java project.
2. Web and JVM developer with a decade of
experience
Husband of Dad of
OSS contributor
2GM Team Member at OCI
ABOUTME
ZACHARY KLEIN, SENIOR SOFTWARE ENGINEER
ZACHARY KLEIN - APACHECON @HOME - SEPTEMBER 30, 2020
💇 🙆 👸 👶🙋
4. ZACHARY KLEIN - APACHECON @HOME - SEPTEMBER 30, 2020
WHATISMICRONAUT?
• A framework for microservice & serverless applications
• Leverages Ahead Of Time (AOT) for DI, AOP, and
configuration injection
• Reactive HTTP layer built on Netty
• Declarative HTTP Client
• “Natively Cloud Native”
• Accompanied by a suite of official and community-
contributed integrations and libraries
5. ZACHARY KLEIN - APACHECON @HOME - SEPTEMBER 30, 2020
WHATCANYOUBUILDWITHMICRONAUT?
• Microservices
• Serverless Applications
• Message-Driven Applications with Kafka/Rabbit
• CLI Applications
• Android Applications
• Anything with static void main(String..args)
6. ZACHARY KLEIN - APACHECON @HOME - SEPTEMBER 30, 2020
WHATMAKESMICRONAUTDIFFERENT?
• Ahead of Time (AOT) Compilation
• No Reflection, Runtime Proxies, or Dynamic Classloading
• Optimized for GraalVM (and standard JVM)
• Natively Reactive
• Capable of running in low-memory environments with sub
second startup time
• Polyglot: supports Java, Kotlin, and Groovy
7. ZACHARY KLEIN - APACHECON @HOME - SEPTEMBER 30, 2020
WHATMAKESMICRONAUTDIFFERENT?
• Configurations offered for…
• Cloud platforms (AWS, Google Cloud, Microsoft Azure)
• Messaging frameworks (Kafka, RabbitMQ, nats.io)
• Data access (MongoDB, Neo4j, Redis, SQL/JDBC, Cassandra
• Open API documentation (Swagger)
• Metrics libraries (Micrometer, rate limiting libraries)
• Server-side view rendering
8. ZACHARY KLEIN - APACHECON @HOME - SEPTEMBER 30, 2020
MICRONAUTANDGROOVY
• First-class support for Groovy
• Controllers, filters, beans, factories, configuration
• @MicronautTest for Spock
• AST Transformations
• Static Compilation
• Interoperability
10. ZACHARY KLEIN - APACHECON @HOME - SEPTEMBER 30, 2020
DEPENDENCYINJECTION&AOP
• Full Featured Dependency Injection (DI) Container
• JSR-330 Compliant
• Minimizes Runtime Reflection
• AOP APIs
11. ZACHARY KLEIN - APACHECON @HOME - SEPTEMBER 30, 2020
Generated Bytecode resides in
the same package as your source
code - your code is never altered
by Micronaut
12. ZACHARY KLEIN - APACHECON @HOME - SEPTEMBER 30, 2020
import javax.inject.Singleton
@Singleton
class MessageHelper {
String createMessage() { // … }
}
Mind the package!
13. ZACHARY KLEIN - APACHECON @HOME - SEPTEMBER 30, 2020
import io.micronaut.http.annotation.Controller
import io.micronaut.http.annotation.Get
import javax.inject.Inject
@Controller("/")
class HelloController {
@Inject
MessageHelper messageHelper
// ...
}
14. ZACHARY KLEIN - APACHECON @HOME - SEPTEMBER 30, 2020
import io.micronaut.http.annotation.Controller
import io.micronaut.http.annotation.Get
@Controller("/")
class HelloController {
MessageHelper messageHelper
public HelloController(MessageHelper messageHelper) {
this.messageHelper = messageHelper
}
// ...
}
15. ZACHARY KLEIN - APACHECON @HOME - SEPTEMBER 30, 2020
CONFIGURATION
• Configuration formats: YML (default), Groovy, JSON, Java
Properties
• Environment detection and env-specific config
• Configuration injection via annotations or
@ConfigurationProperties
info.demo.string = "demo string"
info.demo.number = 123
info.demo.map = [key: 'value',
other_key: 123]
application.groovy
16. ZACHARY KLEIN - APACHECON @HOME - SEPTEMBER 30, 2020
CONTROLLERS
package example
import io.micronaut.http.annotation.Controller
import io.micronaut.http.annotation.Get
@Controller('/')
class GroovyHelloController {
@Get('/hello/{name}')
String hello(String name) {
"Hello $name From Groovy"
}
}
17. ZACHARY KLEIN - APACHECON @HOME - SEPTEMBER 30, 2020
CLIENTS
package example
import io.micronaut.http.annotation.Controller
import io.micronaut.http.annotation.Get
@Client(‘/') // or (id = ‘service-id’)
class GroovyHelloClient {
@Get('/hello/{name}')
String hello(String name)
}
18. ZACHARY KLEIN - APACHECON @HOME - SEPTEMBER 30, 2020
MANAGEMENTENDPOINTS
• Provided by the micronaut-management library
• Similar conceptually to Actuator endpoints in Spring
Boot/Grails
• Endpoints can be defined as sensitive (requiring
authentication)
• Support GET, POST, and DELETE requests
• Can be exposed via JMX
• Custom endpoints supported
19. ZACHARY KLEIN - APACHECON @HOME - SEPTEMBER 30, 2020
/beans Returns information about the loaded bean definitions in
the application
/info Returns static information from the state of the
application
/health Returns information about the "health" of the application
/metrics Return the application metrics. Requires the micrometer-
core configuration on the classpath
/refresh Refreshes bean state
/routes Returns information about URIs available to be called for
your application
/stop Shuts down the application server (disabled by default)
/loggers View and mutate logging configuration (e.g, POST to change
log levels at runtime)
/env Returns all currently resolved configuration properties
DEFAULT MANAGEMENT ENDPOINTS
20. ZACHARY KLEIN - APACHECON @HOME - SEPTEMBER 30, 2020
MICRONAUT&GROOVY
• Groovy is a 1st class language in Micronaut!
• Applications can be generated with Groovy
as the default language (e.g, code-gen for
controllers, clients, Application class, etc)
• Groovy supported as configuration syntax
• Compile-time DI/AOP provided using Groovy
AST Transformations
• Groovy classes can also be used within Java
Micronaut apps (e.g, Spock tests, helper/util
classes)
❤
21. ZACHARY KLEIN - APACHECON @HOME - SEPTEMBER 30, 2020
MICRONAUT&GROOVY
• Groovy can be used for:
• Controllers & Clients
• Filters
• All bean types
• AOP advice
• Configuration
• Serverless functions
❤
22. ZACHARY KLEIN - APACHECON @HOME - SEPTEMBER 30, 2020
“ADEVELOPMENTPLATFORMTO
QUICKLYGENERATE,DEVELOP,&
DEPLOYMODERNWEBAPPLICATIONS
&MICROSERVICEARCHITECTURES.”
HTTPS://WWW.JHIPSTER.TECH
23. ZACHARY KLEIN - APACHECON @HOME - SEPTEMBER 30, 2020
WHATISJHIPSTER?
• Project generator for modern JVM web apps
• Originally designed for Spring Boot and Angular
• Now supports React and Vue.js frontends, and Micronaut as a
backend via the Hipster blueprint
• Provides user admin UI, management UI, and “scaffolding” views for
database entities
• Offers features to easily enable OAuth2 authentication
• JDL (JHipster Domain Language) can be used to define the domain
model (and project options) for your app
24. ZACHARY KLEIN - APACHECON @HOME - SEPTEMBER 30, 2020
JHIPSTER&MICRONAUT
• Development sponsored by Object Computing, Inc
• Custom Blueprint supplies a Micronaut backend
• Still in active development!
• Features currently supported include:
• Maven (default) or Gradle
• MySQL, Postgres, H2
• JWT or OAuth 2.0 authentication
• Angular or React client app
25. ZACHARY KLEIN - APACHECON @HOME - SEPTEMBER 30, 2020
CREATINGAJHIPSTERAPPLICATION
1. Install MHipster
◦ npm install -g generator-jhipster-micronaut
2. Create a new folder for your application
3. Start MHipster
◦ mhipster
26. ZACHARY KLEIN - APACHECON @HOME - SEPTEMBER 30, 2020
JHIPSTER/MICRONAUT+GROOVY!
• JHipster projects use Java only by default, :( however…
• Groovy can be added to the project with fairly minimal build
configuration! :)
• Groovy can be used for project configuration (?)
• Micronaut’s joint-compilation support for Groovy allows
bidirectional DI within your app
27. ZACHARY KLEIN - APACHECON @HOME - SEPTEMBER 30, 2020
DEMO!DEMO!DEMO!
28. ZACHARY KLEIN - APACHECON @HOME - SEPTEMBER 30, 2020
WRAPUP
• Micronaut is a powerful, performant framework for JVM apps -
including Groovy!
• JHipster allows you to quickly bootstrap a full-featured
application with Micronaut with very little coding
• With a bit of custom config, you can take advantage of Groovy
and Micronaut’s support for the Groovy language within your
JHipster project
• Approach is applicable to any Micronaut project (not just
JHipster)
❤
29. ZACHARY KLEIN - APACHECON @HOME - SEPTEMBER 30, 2020
QUESTIONS?
30. ZACHARY KLEIN - APACHECON @HOME - SEPTEMBER 30, 2020
THANKYOU
ZACHARY KLEIN
SENIOR SOFTWARE ENGINEER
GRAILS & MICRONAUT CORE TEAM MEMBER
KLEINZ@OBJECTCOMPUTING.COM
@ZACHARYAKLEIN
https://micronaut.io
https://objectcomputing.com/resources/events
SAMPLE CODE: HTTPS://GITHUB.COM/ZACHARYKLEIN/GROOVY-JHIPSTER