How to setup java enviroment on server

Just to generalize all that I studied from administration field, I decided to write all steps needed to setup your java environment on the web. What will we need? Server/local machine.Say, you need to deploy your app on the web and you need a server. I will be using digitalocean for that purpose. Of course, you will need ssh access. Java Development Kit. I will be using jdk 1.7 Maven build tool. For building apps. We can setup as much tools, as we want(Ant, Gradle), I choosed maven because I use it in my daily development. Setting up ssh key If you already have ssh key , then you are free to skip this part. Go to your terminal and type ssh-keygen -t rsa You will be asked to enter ssh key location - I choosed ~/.ssh/id_rsa_example After that, executed: cat ~/.ssh/id_rsa_example.pub You will get public key, that you need to store in your digitalocean instance in SSH page Name this ssh and copy output from previous cat procedure. PS - Adding your ssh to digitalocean menu means, that when you will create server instance and choose that ssh key in wizard - it will automatically appear in server instance...

Develop your Angular.js application with Yeoman, Grunt and Bower

I position myself as backend developer, but I truly undestand, that I should know more about frontend world. So, by this post, I will start investigating frontend world. This time I will try angular.js - popular framework for building responsive web applications. Notice, that raw angular.js withour any thirdparty libraries is not so powerful, so I will be using Yeoman, Grunt and Bower in this article for convenient work. Expectation This tutorial will cover: Generating of bare angular.js project. Use Grunt to make testing Use Grunt to deploy application Use Bower to add thirdparty plugins Making some little changes to our application. I assume that you have already installed npm package manager. Prerequisites To be confident during this tutorial I recommend you to have the following skills and resources available: Basic knowledge of command line node.js and npm Knowledge of HTML, CSS, JS Ready, and tested Vanilla JS framework :D (Just joke) Resources You can find this project on his GitHub page Installation Before installation, I should say some words about setting up npm. When I first downloaded and installed npm on OS X and tried to configure project from various tutorials - I received plenty of permission exceptions in...

Testing RESTful CRUD Web Service with Gatling Tool

If you follow the right way of designing your web app, and choosed RESTful architecture, then it should be easy for you to test your appplication. By the REST style, you should implement CRUD operations for each entity in your application. What does it mean: You should be able to Create,Read, Update, Delete(CRUD) your entities. You should provide statuses for each operations. For example, for Create operation you should have 201 status in case of succesful operation. You application must have good exception handling. For example, if you will make GET request for retrieving some entity called person with id - 1, and there will be no such record in your storage with this id, then you need to tell your user, that there is no such person, and set status to 404(Not found) So, given that you will keep in mind all information above and will design your app with such instructions. Now it’s time to write some tests. Which framework you should choose? I choosed Gatling framework. Reasons: It runs on jvm It has maven module Configuration As I mentioned above, I will use maven for building my app. So, I will create a separate module for running...

Getting in touch with Liquibase Migration Tool

Have you experienced a situation, when you had a database in your system, and you needed to migrate all it’s structure, to, say, another database ? Of course, you faced such situations and, of course, you manually copied all data from one server instance to another ? Something familiar ? Alternative approach How about idea of writing high-level instructions on how to deal with your database ? For example, you say “Create this table, and add this column , and insert this index, …” only once and all subsequent times you will just reuse this instructions ? Such idea is called “Database migration tool”, there is several migration frameworks for java, but I will show how to work with single tool - liquibase. The idea is that you store this instructions in xml files and when you run your liquibase migration script for the first time, liquibase will create two tables in your database databasechangelog and databasechangeloglock, where all information about running migrations kept. Say, you have only one migration changeset To run such script I use maven, here is pom.xml,as usual mvn liquibase:update If you wish, you can run liquibase from command line, the only thing you need is...

Spark - Micro Web Framework for creating web applications with minimal effort

Today I am going to write few words about Spark framework - micro framework for rapid web application development. Requirements Java 8 installed. We’re goind to use lambdas. Maven 3.+ Eclipse IDE Creating project Navigate to your project desired location and execute in terminal: mvn archetype:generate -DgroupId=org.ivanursul.spark -DartifactId=spark-example -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false Then open your IDE and import maven project Adding dependency To include required libraries just add one dependency <dependency> <groupId>com.sparkjava</groupId> <artifactId>spark-core</artifactId> <version>2.1</version> </dependency> Don’t forget to add maven-compiler-plugin Now you are ready to write some code. Official site says, that it is enough to write something like import static spark.Spark.*; public class HelloWorld { public static void main(String[] args) { get("/hello", (req, res) -> "Hello World"); } } and after execution of program you car test this app by typing http://localhost:4567/hello Seems to be very easy, but let’s try something harder. Implementing CRUD operations To implement CRUD(create, remove, update, delete) for, say, person entity, we will gonna need: DTO(Person) Serializer/Deserializer(GSON? :) ) Note, that I will do it as simple, as I can, without any structures, just for testing this framework. Let’s start Add gson dependency <dependency> <groupId>com.google.code.gson</groupId> <artifactId>gson</artifactId> <version>2.3.1</version> </dependency> Create person class Create main class That seems to...