Developing a web application
The aim here is to combine the usage of the cassandra-maven-plugin
with the jetty-maven-plugin
to make development testing of the web application a lot easier. The developer does not have to manually install either Apache Cassandra or a Servlet container.
Note: the following examples assume you have put a reference to both cassandra-maven-plugin
and jetty-maven-plugin
into your pom.xml
, e.g. for cassandra-maven-plugin
you would add the following:
<project> ... <build> ... <plugins> ... <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>cassandra-maven-plugin</artifactId> <version>4.0.0</version> </plugin> ... </plugins> ... </build> ... </project>
If you cannot modify the pom.xml
then you may have to specify the full coordinates for the goals, i.e. in stead of calling cassandra:start
you would have to call org.codehaus.mojo:cassandra-maven-plugin:4.0.0:start
unless you are happy using the latest version of the plugin.
From the command line, we can get almost all that we want from a simple
mvn cassandra:start jetty:run
If the web application is expecting keyspaces to be defined, we can use a CQL script to create the keyspaces for us. We create a file called src/cassandra/cql/load.cql
. By default cassandra:start
will run this script if the cassandra instance has not been created yet. If the automatic detection does not work for you, you can invoke cassandra:load
manually.
mvn cassandra:start cassandra:load jetty:run
Thereafter we can skip the cassandra:load
unless we run mvn clean
and the automatic detection does not work again.
If we actually want to wipe all the data between Maven runs, we would use:
mvn cassandra:delete cassandra:start jetty:run
if relying on the auto-detection, otherwise we would use
mvn cassandra:delete cassandra:start cassandra:load jetty:run
Trademarks
Apache, Apache Maven, Apache Cassandra, Maven, Cassandra and the Apache feather logo are trademarks of The Apache Software Foundation.