Configuration
The configurations in this page can be set from several sources in the following order:
- the operating system's environment variables; for instance, an environment variable can be set with
export DB_URL="jdbc:mysql://db/elide?serverTimezone=UTC"
- the Java system properties; for example, a Java system property can be set using
System.setProperty("DB_URL", "jdbc:mysql://db/elide?serverTimezone=UTC")
- a .properties file placed under CLASSPATH. This file can be put under
src/main/resources
source directory with contents, for example,DB_URL=jdbc:mysql://db/elide?serverTimezone=UTC
Core Properties
The following configurations can be placed in the properties file called application.properties
- MODEL_PACKAGE_NAME: The fully qualified package name that contains a set of Elide JPA models
JPA DataStore
The following configurations can be placed in the properties file called jpadatastore.properties
-
DB_USER: Persistence DB username (needs have both Read and Write permissions).
-
DB_PASSWORD: The persistence DB user password.
-
DB_URL: The persistence DB URL, such as "jdbc:mysql://localhost/elide?serverTimezone=UTC".
-
DB_DRIVER: The SQL DB driver class name, such as "com.mysql.jdbc.Driver".
-
DB_DIALECT: The SQL DB dialect name, such as "org.hibernate.dialect.MySQLDialect".
-
HIBERNATE_HBM2DDL_AUTO: What to do with existing JPA database when webservice starts; can be one of the 4 values:
- validate: validate that the schema matches, make no changes to the schema of the database. This is the default value of HIBERNATE_HBM2DDL_AUTO
- update: update the schema to reflect the entities being persisted
- create: creates the schema necessary for your entities, destroying any previous data.
- create-drop: create the schema as in create above, but also drop the schema at the end of the session. This is great in development or for testing.
noteThis property is exactly the same as Hibernate
hibernate.hbm2ddl.auto
property.
CI/CD
In addition to the ones mentioned in general CI/CD configs, these GitHub Action Secrets needs to be setup:
Secret Name | Definition | How to Get |
---|---|---|
APPLICATION_PROPERTIES | The contents of the src/main/resources/application.properties mentioned above | See Core Properties section above |
JPADATASTORE_PROPERTIES | The contents of the src/main/resources/jpadatastore.properties mentioned above | See JPA DataStore section above |
DATA_MODELS_PRIVATE_REPO_TOKEN | The GitHub Fine-grained token with at least "Read access to code and metadata" repository permissions to the Elide data models repo | Creating a fine-grained personal access token |
DATA_MODELS_PRIVATE_REPO_ORG | The org/user name of the GitHub repo for Elide data models | For this example, DATA_MODELS_PRIVATE_REPO_ORG is "QubitPi" |
DATA_MODELS_PRIVATE_REPO_NAME | The name of the GitHub repo for Elide data models | For this example, DATA_MODELS_PRIVATE_REPO_NAME is "jersey-webservice-template" |
CI/CD Chain
Jersey Webservice Templates adopts the best CI/CD strategies by incorporating its sister projects, jersey-webservice-template-jpa-data-models and
jersey-webservice-template-jpa-data-models-acceptance-tests, into its CI/CD pipeline. Any PR merge into jpa-elide
branch will trigger the
CI/CD of its data model, which then triggers
CI/CD of data model's acceptance tests.
The triggering of its direct downstream project is done through GitHub Actions. See the triggering job in CI/CD definition file. Basically, the triggering is proxied to peter-evans/repository-dispatch:
triggering:
name: Triggering data model CI/CD
runs-on: ubuntu-latest
steps:
- name: Trigger data model CI/CD
uses: peter-evans/repository-dispatch@v2
with:
token: ${{ secrets.MY_DATA_MODEL_CICD_TRIGGER }}
repository: my-org/my-data-model-repo
event-type: my-webservice-repo-changes
For MY_DATA_MODEL_CICD_TRIGGER token, it is recommended to use a fine-grained personal access token with the following permissions on the target repository (i.e. my-data-model-repo):
- contents: read & write
- metadata: read only (automatically selected when selecting the contents permission)
In downstream project CI/CD workflow, add the following to the on-clause:
"on":
repository_dispatch:
types: [my-webservice-repo-changes]
Note that how my-webservice-repo-changes
is used to bridge the event dispatcher (Jersey Webservice Template) and event subscriber (data model project).