4 easy steps for setting up Cassandra DB in Mac.

I, like millions of people in this new millennia, believe in technology. And whenever a cool thing comes out, it immediately excites me. I start reading about it and often times I do get sold quite easily. And due to this reason, I do setup a lot of things on my machine and this is the process I loathe.

And my experience with Cassandra not a piece of cake either! And now that I think about it, it is all my fault. Here below, I will show how ridiculously simple is the setup of Cassandra in a Mac machine. ( It should be similar in the Windows world too but I will write a post on it as soon as I setup one.)

So, here are the steps.

  1. Download.
    • Go to http://cassandra.apache.org/download. There should be a “Latest Version” section in the page here. Check out the latest version by clicking on the version name.  As of date, the latest release is 3.9 and when I clicked the link, it took me to http://www.apache.org/dyn/closer.lua/cassandra/3.9/apache-cassandra-3.9-bin.tar.gz
    • Choose any mirror site and download the tar ball.
    • Untar it any location you prefer.
    • For example sake let’s pretend you downloaded it to the desktop
  2. Give Permissions.
    • Using either terminal or the finder, go to desktop and give Read&Write permissions to all users and staff.
  3. Run
    • Now open up a terminal, navigate to the bin folder.
    • Type ./cassandra
    • After a couple of seconds, your Cassandra DB is up and running.
  4. Open a new terminal tab and type the following the bin folder location.
    • ./cqlsh
    • This command will open up the cqlsh prompt where you will be able to run your CQL commands

 

Accessing Properties files in Spring.

Today, I literally spent over 3 hours to find the easiest way to access a properties file in a Spring project. What I am surprised is, with all the so much documentation about Spring, it was not an easy find. I hope someone will find this and save their time.

The process is very simple and could be achieved in 2 straight forward steps.

1.Create a properties file in

src/main/resources.

Let us call it

test.properties

2.Put this line in your code.

Properties props = PropertiesLoaderUtils.loadAllProperties("test.properties");

That’s it. Now you can use these properties as you wish.

eg., System.out.println(props.getProperty("username"));

Now, remember, you need this line too!

import org.springframework.core.io.support.PropertiesLoaderUtils;

Enjoy!

Building a .war file using maven.

This post will be short and sweet. I hope this helps someone.
Recently I had an interesting requirement. I developed a maven project which was building into a jar. After working many hours on the code, I was on cloud nine that everything was working great. Then I had a meeting with my Infrastructure team. I was told “very politely”, that they will not be able to deploy a jar file and will definitely need a .war file.

Since I was using maven, I was gleaming inside that this will be a two minute change. I opened up my eclipse and my pom clearly shows the packaging types.
Without hesitation, I switched from jar to war and ran the build. I was psyched up until the build failed within a second.

With a quite a bit of research, I found this beautiful plugin.

<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
<configuration>
<warSourceDirectory>WebContent</warSourceDirectory>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>

 
Once I plug it in the pom, the war was build beautifully. Oh the world is so blissful!