Spring 5 REST / GraphDB : Part 1 – Environment Setup

Quite some time since I had worked on web application development.

Have been planning on developing a framework for analytics, where the data sources and relation between sources result in the need of graph databases.

So thought of kick starting a PoC with Spring 5, Tomcat 9, ArangoDB 3.x (>3.3).  Here it goes from scratch.  The intention is to record all kick start procedure so that any new comer to such needs finds it helpful.

Created a VM (Debian Stretch)
Install OpenJDK 1.8
Install Maven 3.3.x

Install Eclipse IDE

Create a new Dynamic Web Project

Convert to Maven Project


Edit build path and remove JRE 1.7 System Library if found

Add JRE 1.8

Edit and update the generated pom.xml – Set properties for versions of Java / Spring / Servlets, Add spring dependencies and update build for deploying to tomcat.

<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">
 <modelVersion>4.0.0</modelVersion>
 <groupId>GraphDBPoC</groupId>
 <artifactId>GraphDBPoC</artifactId>
 <version>1.0</version>
 <packaging>war</packaging>
 <properties>
   <failOnMissingWebXml>false</failOnMissingWebXml>
   <java.version>1.8</java.version>
   <spring.version>5.0.6.RELEASE</spring.version>
   <servlets.version>3.1.0</servlets.version>
 </properties>
 <dependencies>
   <!-- Servlet Dependency -->
   <dependency>
     <groupId>javax.servlet</groupId>
     <artifactId>javax.servlet-api</artifactId>
     <version>${servlets.version}</version>
     <scope>provided</scope>
   </dependency>
   <!-- Spring Dependency -->
   <dependency>
     <groupId>org.springframework</groupId>
     <artifactId>spring-core</artifactId>
     <version>${spring.version}</version>
   </dependency>
   <dependency>
     <groupId>org.springframework</groupId>
     <artifactId>spring-context</artifactId>
     <version>${spring.version}</version>
   </dependency>
   <dependency>
     <groupId>org.springframework</groupId>
     <artifactId>spring-web</artifactId>
     <version>${spring.version}</version>
   </dependency>
   <dependency>
     <groupId>org.springframework</groupId>
     <artifactId>spring-webmvc</artifactId>
     <version>${spring.version}</version>
     </dependency>
   </dependencies>
   <dependency>
     <groupId>com.fasterxml.jackson.core</groupId>
     <artifactId>jackson-databind</artifactId>
     <version>${jackson.version}</version>
   </dependency>
   <build>
     <sourceDirectory>src/main/java</sourceDirectory>
     <resources>
       <resource>
         <directory>src/main/resources</directory>
       </resource>
     </resources>
     <plugins>
       <plugin>
         <artifactId>maven-compiler-plugin</artifactId>
         <version>3.7.0</version>
         <configuration>
           <source>${java.version}</source>
           <target>${java.version}</target>
         </configuration>
       </plugin>
       <plugin>
         <artifactId>maven-war-plugin</artifactId>
         <version>3.0.0</version>
         <configuration>
           <warSourceDirectory>WebContent</warSourceDirectory>
         </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.tomcat.maven</groupId>
        <artifactId>tomcat7-maven-plugin</artifactId>
        <version>2.2</version>
        <configuration>
          <path>/</path>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>

Update Maven Project

Install Apache Tomcat

#cd /usr/local/
#wget http://www-eu.apache.org/dist/tomcat/tomcat-9/v9.0.8/bin/apache-tomcat-9.0.8.tar.gz
#tar -xvzf apache-tomcat-9.0.8.tar.gz 
#ln -fs /usr/local/apache-tomcat-9.0.8 tomcat

Optionally create setenv.sh

#cd /usr/local/tomcat
#nano bin/setenv.sh

Contents of file

export CATALINA_OPTS="$CATALINA_OPTS -Xms8192m"
export CATALINA_OPTS="$CATALINA_OPTS -Xmx8192m"
export CATALINA_OPTS="$CATALINA_OPTS -Xss1920k"
export CATALINA_OPTS="$CATALINA_OPTS -XX:+UseParallelGC"
export CATALINA_OPTS="$CATALINA_OPTS -XX:MaxGCPauseMillis=1500"
export CATALINA_OPTS="$CATALINA_OPTS -XX:GCTimeRatio=9"
export CATALINA_OPTS="$CATALINA_OPTS -XX:+DisableExplicitGC"

Configure Run Time Environment in Eclipse (Window->Preferences->Server->Runtime Environments)



Configure Server





We are done with setting up the development environment.