How to create and use RestClient with EHRBase SDK in my Maven project?

How to create and use RestClient with EHRBase SDK in my Maven project?
Specifically, how to specify the dependencies in the pom.xml? OR, should I build the SDK jar(s) locally or download them from a repo such as jitpack.io, then add them to my project’s Build Path?

For example, I want to get the following Java code working:

DefaultRestClient client = new DefaultRestClient(
    new OpenEhrClientConfig(new URI("http://localhost:8080/ehrbase/")),
    templateProvider);

Snippet source: EHRBase Documentation: 4.2.1.1.2. Client setup

Similar topic: EHRBase questions

Thanks in advance.

Hello @linforest

You’re referring to the old version of the documentation. The current one is available at https://docs.ehrbase.org/, but I can’t find the page you’re looking for.

There is no need to use jitpack.io anymore. All artifacts are published on Maven Central, so you only have to add the client dependency into your pom.xml:

<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <!-- ... -->

    <properties>
        <!-- ... -->
        <!-- Dependency Versions -->
        <ehrbase.version>2.17.0</ehrbase.version>
        <!-- ... -->
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.ehrbase.openehr.sdk</groupId>
            <artifactId>client</artifactId>
            <version>${ehrbase.version}</version>
        </dependency>
        <!-- ... -->
   <dependencies>

    <!-- ... -->
</project>
5 Likes

Hi, @subigre. Unfortunately, the site of the latest official documentation is not accessible for us. Thanks a lot for your help.

Hello, @birger.haarbrandt. Is there any alternatives for the latest official documentation site ? When I try to access the site, my web browser always complains something like:

This website cannot be accessed
docs.ehrbase.org has too long a response time.

@subigre Based on your suggetsion, it’s found that the problem was possibly caused by the mirror in Maven settings.xml and the redundant parent tag ‘dependencyManagement’ for the dependencies.

    <dependencyManagement>
        <dependencies>
            <dependency>
			    <groupId>org.ehrbase.openehr.sdk</groupId>
			    <artifactId>client</artifactId>
			    <version>2.17.0</version>
			</dependency>
...

The command ‘mvn clean install’ is working properly now although I still don’t really master the pom setting stuff.

Again, Thanks.

2 Likes