Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

API example: Java + Spark

This small application demonstrates how you might set up a web server using Java and Spark with RESTful routes to accept your modern-treasury-js form submissions without having to handle sensitive data.

This example makes use of the official Java client library for the Modern Treasury API.

Note that it is not necessary to use the Spark framework. In this example it is used to organize various API actions into distinct application routes, but one could just as easily implement these API actions within another application framework.

Use

Local

  1. Install dependencies

The Modern Treasury Java library is distributed via Maven Central:

<dependency>
        <groupId>com.moderntreasury</groupId>
        <artifactId>modern-treasury-java</artifactId>
        <version>2.14.0</version>
</dependency>

The Spark Web Framework is distributed via Maven Central

<dependency>
    <groupId>com.sparkjava</groupId>
    <artifactId>spark-core</artifactId>
    <version>2.9.4</version>
</dependency>
  1. Start the server
mvn clean compile && mvn exec:java -Dexec.mainClass="com.moderntreasury.examples.App"
  1. Open http://localhost:9001