Search:

Search all manuals
Search this manual
Manual
Couchbase Client Library: Java 1.1
Community Wiki and Resources
Download Client Library
JavaDoc
Couchbase Developer Guide 2.0
Couchbase Server Manual 2.0
Java Client Library
SDK Forum
Wiki: Java Client Library
Additional Resources
Community Wiki
Community Forums
Couchbase SDKs
Parent Section
2.2 Preparations
Chapter Sections
Chapters

2.2.1. Project Setup

Inside your IDE, go ahead and create a new Web Project, either with or without Maven support. The getting started guide provides information on how to include the Couchbase SDK and all the needed dependencies in your project (the same concepts apply here). Also make sure to include Google GSON or your favorite JSON library as well. This turorial uses a directory structure like this:

|-target
|-src
|---main
|-----java
|-------com
|---------couchbase
|-----------beersample
|-----resources
|-----webapp
|-------WEB-INF
|---------beers
|---------breweries
|---------maps
|---------tags
|---------welcome
|-------css
|-------js

If you're using Maven, then you'll also have a pom.xml in the root directory. Here is a sampe pom.xml for your reference (the full source is available from the repository mentioned at the beginning of the tutorial):

<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>com.couchbase</groupId>
    <artifactId>beersample-java</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>war</packaging>

    <name>beersample-java</name>

    <repositories>
        <repository>
            <id>couchbase</id>
            <name>Couchbase Maven Repository</name>
            <layout>default</layout>
            <url>http://files.couchbase.com/maven2/</url>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
    </repositories>
    
    <dependencies>
        <dependency>
            <groupId>couchbase</groupId>
            <artifactId>couchbase-client</artifactId>
            <version>1.1.4</version>
        </dependency>
        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <version>2.2.2</version>
        </dependency>
        <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-web-api</artifactId>
            <version>6.0</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>
</project>

In order to make the application look pretty, we're incorporating jQuery and Twitter Bootstrap. You can either download the libraries and put it in their appropriate css and js directories (under webapp), or clone the project repository and use it from there. Either way, make sure to have the following files in place:

From here on, you should have a barebones web application configured that has all the dependencies included. We'll now move on and configure the beer-sample bucket the way we need it.