This is a spring-native polyglot server that can be quickly deployed.
This project is developed in GraalVM environment, so please configure the corresponding environment when you want to run this project as SVM, see Get Started with GraalVM.
This project can be easily build with maven, run the following goal:
mvn clean package
Then run the followings to start the server:
sh ./bin/start.sh
or
java -jar target/cobnet.jar
This project has been configured to let you generate either a lightweight container or a native executable.
Default source is already configured good to be build native or container. But if you have other modified we can use agent and some tool to help for configuration needs, to use these options the following needs to be setup:
Native images are built ahead of runtime and their build relies on a static analysis of which code will be reachable.
First build a jvm mirror
mvn clean package
Then run with the agent
java -agentlib:native-image-agent=config-merge-dir=src/main/java/ -jar target/cobnet.jar agent
A script which written in Python3 to help you append Graal Native needed proxy into extra-proxy-config.json.
From project root directory run:
cd script
Then run the script:
python3 ProxyHelper.py
If you're already familiar with Spring Boot container images support, this is the easiest way to get started with Spring Native. Docker should be installed and configured on your machine prior to creating the image, see the Getting Started section of the reference guide.
-
Docker atlease 10GB memory in docker preferences. see Out of memory error when building the native image
-
Docker-Compose 18.06.0+ needs to be installed.
####To create the docker image and container by compose, there is two options.
#####JVM:
mvn -Dredis-host=redis -Ddb-host=db clean install -Pdocker -Ddocker-target=jvm
#####Native:
mvn -Dredis-host=redis -Ddb-host=db clean install -Pdocker -Ddocker-target=native
To start the app you can run as follows:
docker start -a cobnet
Use this option if you want to explore more options such as running your tests in a native image. The GraalVM native-image compiler should be installed and configured on your machine, see the Getting Started section of the reference guide.
- Graalvm-Native needs to be installed.
- Reflection Use in Native Images.
- To add a language to native image.
To create the executable, run the following goal:
mvn clean package -Pnative
Then, you can run the app as follows:
sh ./bin/start.sh
or
target/cobnet
For further reference, please consider the following sections:
- Spring Redis
- Official Apache Maven documentation
- Spring Boot Maven Plugin Reference Guide
- Create an OCI image
- Spring Native Reference Guide
- Spring Data JDBC
- Spring Data JPA
- Spring Web
- Spring Cloud Eureka Client
- GraalVM and Graalvm SDK
The following guides illustrate how to use some features concretely:
- Using Spring Data JDBC
- Accessing Data with JPA
- Building a RESTful Web Service
- Serving Web Content with Spring MVC
- Building REST services with Spring
- Spring Boot with Graalvm
- Spring Cloud with Graalvm
- Graalvm Options
These additional references should also help you: