https://github.com/panga/hammock-jpms
Hammock MicroProfile (CDI + JAXRS + JSON) HelloWorld using Java Module System (JPMS)
https://github.com/panga/hammock-jpms
hammock java jdk10 jpms
Last synced: 23 days ago
JSON representation
Hammock MicroProfile (CDI + JAXRS + JSON) HelloWorld using Java Module System (JPMS)
- Host: GitHub
- URL: https://github.com/panga/hammock-jpms
- Owner: panga
- License: apache-2.0
- Created: 2018-06-06T21:56:55.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-07-26T19:47:30.000Z (almost 7 years ago)
- Last Synced: 2025-03-24T15:03:54.832Z (about 1 month ago)
- Topics: hammock, java, jdk10, jpms
- Language: Java
- Homepage: https://medium.com/criciumadev/first-microprofile-io-application-using-java-module-system-33b83ae939c9
- Size: 26.4 KB
- Stars: 4
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Hammock JPMS
[Hammock MicroProfile](https://github.com/hammock-project/hammock) (CDI + JAX-RS + JSON) HelloWorld using Java Module System (JPMS).
The stack uses Weld 3 for CDI, RestEasy 3.5 for JAX-RS and Johnzon 1.1 for JSON
The total size of this example application is around `12mb` and the full Docker image is only `55mb`!
_Note: Tested with JDK 11-ea+23_
## How To
### Package and generate `target/modules` folder (weld profile)
`mvn clean package`
### Package and generate `docker image` (docker + weld profiles)
`mvn clean package -Pweld,docker`
### Package using with OpenWebBeans 2 for CDI (owb profile)
`mvn clean package -Powb`
### Run using the default JRE
`java --module-path target/modules --module hammock.jpms`
### Run using a minimal JRE (35mb)
1. Run jlink to create minimal JRE
```bash
jlink \
--add-modules java.logging,java.xml,java.naming,java.management,jdk.unsupported \
--verbose \
--strip-debug \
--compress 2 \
--no-header-files \
--no-man-pages \
--output target/jlink-image
```2. Run minimal JRE with patch module for `java.beans`:
```bash
target/jlink-image/bin/java \
--patch-module java.base=target/patch/java.beans \
--add-exports java.base/java.beans=johnzon.mapper \
--add-exports java.base/java.beans=org.apache.logging.log4j.core \
--module-path target/modules \
--module hammock.jpms
```_Note: https://github.com/panga/lite-beans was used to patch `java.beans` implementation required by some 3rd party dependencies and remove the requirement of adding `java.desktop` module into the minimal JRE._
### Run using the Docker image
`docker run --rm -it -p 8080:8080 hammock-jpms`
### Test the application
`curl http://localhost:8080/hello`