Getting Started
If this is your first time with the Nemesis Platform, this is the place to start from.
What you’ll need
-
an IDE of your choice - either IntelliJ Idea or Eclipse
Install Java
At the moment the Nemesis Platform requires version of the JDK at least 1.8.0
, so go to the Oracle website and download the latest version of the JDK. Please note that we use maven-enforcer-plugin
so smaller version will simply not build the project.
Install Maven
The platform needs maven in order to build the project. Required version is at least 3.0.0-alpha-1
. Please note that we use maven-enforcer-plugin
so smaller version will simply not build the project.
Configure Maven
To be able to run build the consoles you will need access to the Nemesis company repository. Simply add the following servers to your ~/.m2/settings.xml
file:
<?xml version="1.0" encoding="UTF-8"?>
<settings>
<profiles>
<profile>
<id>nemesis-snapshot</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<repositories>
<repository>
<id>nemesis-samplestore-archetype</id>
<url>https://repository.nemesis.io/artifactory/libs-snapshot/</url>
</repository>
</repositories>
</profile>
</profiles>
<servers>
<server>
<id>nemesis-repository</id>
<username>YOUR_MAVEN_REPO_USERNAME_HERE</username>
<password>YOUR_MAVEN_REPO_PASSWORD_HERE</password>
</server>
<server>
<id>nemesis-repository-releases</id>
<username>YOUR_MAVEN_REPO_USERNAME_HERE</username>
<password>YOUR_MAVEN_REPO_PASSWORD_HERE</password>
</server>
<server>
<id>nemesis-repository-snapshots</id>
<username>YOUR_MAVEN_REPO_USERNAME_HERE</username>
<password>YOUR_MAVEN_REPO_PASSWORD_HERE</password>
</server>
<server>
<id>nemesis-repository-plugins</id>
<username>YOUR_MAVEN_REPO_USERNAME_HERE</username>
<password>YOUR_MAVEN_REPO_PASSWORD_HERE</password>
</server>
<server>
<id>nemesis-samplestore-archetype</id>
<username>YOUR_MAVEN_REPO_USERNAME_HERE</username>
<password>YOUR_MAVEN_REPO_PASSWORD_HERE</password>
</server>
</servers>
</settings>
Create, build and run the Sample Project
Step 1: The Initializr
The easiest way to get started with the Nemesis Platform is to create a sample project and play with it.
To do so please visit the Nemesis initializer and provide the following details:
Group |
What groupID should you project have. |
Artifact |
What artifactID should your project have. |
Version |
What the version of your project must be . |
Name |
What the name of your project is. |
Description |
A short description of your project. |
Package name |
What java package your project sources should be in. |
Nemesis Version |
The version of the Nemesis Platform you want to use. |
In the website console you may see the command, produced by the initializr. Now you are ready to issue the command from the Nemesis Initializer into your command prompt. Soon after, that command will create a project with the name, the artifactId that you specified in the initializer. When the command finishes, you will have your project generated in a folder with the artifactId name.
Step 2: Build the project
To build the project simply run
mvn clean install
from the top of the project.
Please be patient - the first build might take even an hour, as Maven is downloading all the missing artifacts. Subsequent builds, however, should build relatively fast. |
Step 3: Create the database (optional)
You may either create your own database (via MySQL Server, for example), or rely on the default H2 database. Keep in mind that H2 is in-memory database and must not be used for production purposes.
If you opt for creating your own
database, consider its name. It must be the
same as the provided in the initializr value
for the artifactId. If you don’t remember it,
open the src/main/resources/application-[YOUR_DB_OF_CHOICE].properties file
and check the spring.datasource.url property.
|
Something else you need to keep in mind when creating your database - don’t miss configuring the UTF-8 encoding in your server. If using MySQL server, the command looks like that:
[client]
default-character-set=utf8
[mysqld]
innodb_flush_log_at_trx_commit=0
character-set-server = utf8
collation-server = utf8_unicode_ci
init-connect='SET NAMES utf8'
character-set-server = utf8
Step 4: Create the schema for the database
Once the database is created, it is still empty. We need to create tables and indexes. To do so, run the following command:
mvn nemesis:init-schema
The initschema
of the Nemesis Maven plugin will
compare what is in your database, and what is in your JPA models and will create SQL files that update your database to the state of your JPA models. Currently, your database is empty - the SQL files that are generated should contain all of the
create table
and add foreign key constraint
necessary for our database to operate.
Once this command is finished you can see the result in here: src/main/resources/db/migration/
- in this folder there will be subfolders for each of the database drivers that are located in your classpath.
Now that we have the database created, the project built, and the SQL files ready, it is time to import some data. The data for the Nemesis Platform is stored in CSV files located in
src/main/resources/META-INF/import/data/
.
In that folder you will find subfolders with data CSVs for each of the websites: solarapparel (sample b2c website), nemesis (sample cms website) and
polarapparel (sample b2b website).
Step 5: Import the data
The way to import this data in our database is with a process of initialization. The initialization process performs the following steps:
-
creates table structure of the database by importing the SQL file we just generated.
-
imports csv data files from
src/main/resources/META-INF/import/data/
. -
performs synchronization between
Staged
andOnline
catalog.
To start the initialization, run the following command:
mvn nemesis:init-db -Dprofiles=[YOUR_DB_OF_CHOICE]
Wait for the command to finish. This will perform the database initialization, with the profiles property denotes which profile you want to initialize (you
can also combine profiles like -Dprofiles=basic,mysql
). When initializing the platform will look for a folder with the name of the profile and import all the
CSV files from that folder (in our example the basic
folder contains a small set of products).
Step 6: Run the project
Once it’s finished, you are ready to start your website with the Spring Boot Maven plugin:
mvn spring-boot:run -Dspring-boot.run.profiles=[YOUR_DB_OF_CHOICE]
If you are on Windows the spring boot maven plugin will not work. The problem is that Windows has limitation on the command line length, and since we are actually constructing a classpath from all the jars, we eventually get The filename or extension is too long error. In this case we would strongly recommend using Linux or MacOS, but if you have to stick
with Windows, then you can start the project by issuing java -jar target/storefront.war -Dfile.encoding=UTF-8 -Dspring.profiles.active=[YOUR_DB_OF_CHOICE] .
|
When starting the project we also start embedded Redis server and embedded Solr/Elasticsearch server. Solr/Elasticsearch will start on port 8983 and Redis will start on port 6379. Please make sure those ports are not already used by some other program and you have no firewall blocking them.
Step 7: Access the site
The application has started on https://localhost:8112/storefront/en/US/?site={artifactId}-{typeOfProject}
(for example https://localhost:8112/storefront/en/US/?site=demo-b2c
).
To make access to the website easier you can add the following entries in your /etc/hosts
file:
127.0.0.1 localhost
127.0.0.1 nemesis.local
127.0.0.1 solar.local
127.0.0.1 polar.local
127.0.0.1 bank.local
127.0.0.1 telco.local
127.0.0.1 insurance.local
127.0.0.1 logistics.local
and then you will be able to access the correct website using the host specified in the /etc/hosts
file and skip the site
request parameter. Here’s a table that tells you which host corresponds to which website:
nemesis.local |
Samplestore CMS |
solar.local |
Samplestore B2C |
polar.local |
Samplestore B2B |
bank.local |
Samplestore Bank |
telco.local |
Samplestore Telco |
insurance.local |
Samplestore Insurance |
logistics.local |
Samplestore Logistics |
When you browse the websites you might find out that products are missing in the Elasticsearch index.
By default, the products are exported to Elasticsearch daily at 12:00a.m. If you want to show them straight away after initializing a new site you need to start the export cronjob either via the Backend Console or execute this cURL: |
curl -k -v --user admin:nimda -X POST "http://localhost:8111/storefront/platform/job/run/[artifactId]B2CSearchProductExportFullJob"