domingo, 27 de outubro de 2013

MongoDB + Java Course - In progress

MongoDB Course. Home work
=============================

GitHub on
https://github.com/romalopes/hw2-3

- MongoDB Course
Info:
https://education.mongodb.com/courses
Lenght of course: - 7 weeks
Using Maven
to run the project: mvn compile exec:java -Dexec.mainClass=course.BlogController
to test: mvn test
Using Gradle
   to rum the project: gradle run
   to test: gradle test

To create a project with gradle
- copy the directory Gradle to root

1:              - gradle  

2:                  wrapper
3:                      gradle-wrapper.jar
4:                      gradle-wrapper.properties
5:                  ide.gradle
6:          - copy the btch file to root
7:              gradlew (for X)
8:              gradle.bat ( for windows)
9:          - copy settings.gradle to root
10:              Only this inside: rootProject.name = "NAME PROJECT"


- Week 1
- Suports
Based on Json Documents(key, values). It is a document database
In same document Dynamic Schema.  Different collections of data.
- Scalability and performance VS Funcionality
Doesn't support joins and transactions. Documents are hierarchical
- Running
create a directory %MONGO_HOME%\data\db

1:  %MONGO_HOME%/bin/mongo.config  
2:                  ##store data here  
3:                  dbpath=%MONGO_HOME%\data\db  
4:                  ##all output go here  
5:                  logpath=%MONGO_HOME%\log\mongo.log  
6:                  ##log read and write operations  
7:                  diaglog=3  

- Server:
mongod --dbpath data\db
mongod --config %MONGO_HOME%\bin\mongo.config
As a server
mongod --config %MONGO_HOME%\bin\mongo.config --install
net start MongoDB
net stop MongoDB
mongod --remove (remove the service)
- Command line: mongo

Ex:

1:                      mongo test(connects to mongodb already in test collection)  

2:                      use test (switches to test collection)
3:                      show collections
4:                        (collection) (command)
5:                      db.objects.   save({a:1, b:2, c:3})
6:                      db.objects.   save({a:4, b:5, c:6, d:7, e:['a','b']})
7:                      db.objects.find() <- return all documents
8:                      db.objects.find({a:1}) <- Return all documents that have this element
9:                      db.course.hello.save({'name','maths'})
10:                      db.course.hello.find()


- Json
Types of Data
- Array -> list of items -> [...]
- Dictionaries ->associative maps  {key:value} -> {name:"value",city:"value", interests:[ ___, ___, ___]
- Embeded data into documents
If the embeded data exceed 16Mb, because each document should have the maximum of 16Mb
Home Work:
1 - 42
2- 2,3,5
3-366
4- 2805
- Week 2
- CRUD
Create=Insert.  Read=Find.  Update=Update.  Delete=Remove
Does not have a language such as SQL.

1:  - db.people.insert( doc )  
2:              - db.people.find()  
3:              - db.people.findOne({"name": "Anderson"}, {"name":true,"_id":false})  


- all object has a primary key called (_id)
- BSON - Binary JSON Object
- Query
- $gt, $lt,

1:  db.people.findOne({name:{$gt:    "B", $lt:"D"}})  
2:                  db.people.findOne({name:{$gt:    "B"}, {name:{$lt:"D"}} }) --Will return all docs less than D. Ignore the first statement.  


- exists
- To verify if a field exists
- db.people.findOne({name:{ $exists : true}})  -- return all documents that has the field name.
- regex
- db.people.find({name: { $regex : "^A"}}) -> returns everything that starts with A.
ex:db.users.find( {name: {$regex:"q"}, email: {$exists:true} } )
- or //ends with e
- db.people.find( { $or : [ {name: { $regex : "e$" } } , {age : {$exists: true}]})
- db.scores.find( {$or : [ {score : {$lt: 50}}, {score : {$gt: 90}} ]})
- and
- all - return the documents that have all the specified elements in a array
db.accounts.find( { favorites : { $all, [ "a", "b", "c" ] } } )
- in - return all documents that has on of the objects IN a array
db.accounts.find( { name : { $in, [ "Anderson", "Cida"] } } ) -- returns the docs that have Anderson and Cida
- Queries
db.users.find( {email : {work: "romalopes@yahoo.com.br" } } )
or
db.users.find( {email.work: "romalopes@yahoo.com.br" } )
- Cursor


1:                  db.people.insert( {name: "Anderson", email : {work:"111", home:"222"}});  

2:                  db.people.insert( {name: "Cida", email : {work:"111", home:"222"}});
3:                  - cur = db.people.find(); null; //NULL avoid the return.
4:                  - cur.limit(5); null; get only 5 elements.
5:                  - cur.sort( {name: -1 }); null;
6:                  - cur.sort( {name: -1 }).limit(5); null;
7:                  - while(cur.hasNext()) printjson(cur.next());
8:                  - db.scores.find( { type : "exam" } ).sort( { score : -1 } ).skip(50).limit(20)

- count
db.score.count({type:"exam"})
- db.scores.count( {"type":"essay", score: {$gt: 90 } } )
- Update
- db.people.update( { name: "Anderson"} , {name:"Anderson Lopes", address:"114 Hargrave"})
- Creates, remove and replace all the attributes.
- $set
db.people.update( { name: "Anderson"} , {$set: {age:30}} )
- set only the values we want to change.
db.people.update( { name: "Anderson"} , {$inc: {age:3} } )
- increment 3 in age.
- ex:

1:                          db.arrays.insert( {_id:0, a:[1,2,3,4]});  

2:                          db.arrays.update( {_id:0, {$set : {"a.2" : 5 }});
3:                              change the third element from 3 to 5.
4:                          db.arrays.update( {_id:0, {$push : {a : 6 }});
5:                              add at the end of array
6:                          db.arrays.update( {_id:0, {$pop : {a : 1 }}); //remove the last element
7:                          db.arrays.update( {_id:0, {$pop : {a : -1 }}); //remove the first element
8:                          db.arrays.update( {_id:0, {$pushAll : {a : [6, 7, 8, 9 }});
9:                          db.arrays.update( {_id:0, {$pull : {a : 3} }); //remove the element that the value is 3
10:                          db.arrays.update( {_id:0, {$pullAll : {a : [6, 7, 8, 9 }}); // remove all elements with the values in the second array


- $unset (remove a field from a collection)
db.people.update( { name: "Anderson"} , {$unset: {age:1} } )
- Multi-update
Update multiple documents
db.people.update( {} , {$set :{"title": "Dr" } }, {multi: true} );
db.scores.update ( { score: {$lt:70} }, {$inc: {score:20}}, {multi:true});
- Remove a database

1:                  use DATABASE  

2:                  db.dropDatabase()

- remove

1:                  db.people.remove() //remove everything from the collection.  

2:                  db.people.drop() //faster than remove
3:                  db.people.remove( {name:"Alice"})
4:                  db.people.remove( {name: {$gt: "M" }} )
5:                  db.scores.remove( {score: { $lt: 60 }})
6:              - db.runCommand( {getLastError:1})

return the last result of a command.  It can be a error, a result of a update and so on.
With Java
CRUD


1:                  INSERT DBOBject(interface) . BasicDBObject with is a LinkedHashMap<String, Object>  

2:                   BasicDBObject doc = new BasicDBObject();
3:                      doc.put("userName", "anderson");
4:                      doc.put("birthDate", new Date(2344242));
5:                      doc.put("programmer", true);
6:                      doc.put("age", 8);
7:                      doc.put("languages", Arrays.asList("Java", "C++"));
8:                      doc.put("address", new BasicDBObject("street", "114 Hargrave")
9:                                  .append("town", "Paddington")
10:                                  .append("zipCode", 2021));
11:                      { "_id" : "user1",
12:                        "interests" : [ "basketball", "drumming"]    }
13:                      new BasicDBObject("_id", "user1").append("interests", Arrays.asList("basketball", "drumming"));

FIND


1:                  DB courseDB = client.getDB("course");  

2:                      DBCollection collection = courseDB.getCollection("findCriteriaTest");
3:                      collection.drop();
4:                      for(int i=0; i<10; i++) {
5:                          collection.insert(new BasicDBObject( "x", new Random().nextInt(2)).
6:                                                            append("y", new Random().nextInt(100)));
7:                      }
8:                      System.out.println("\n Find All");
9:                      DBCursor cursor1 = collection.find();
10:                      try {
11:                          while(cursor1.hasNext()) {
12:                              DBObject all = cursor1.next();
13:                              System.out.println(all);
14:                        }
15:                      } finally {
16:                          cursor1.close();
17:                      }
18:                      DBObject query = new BasicDBObject("x", 0)
19:                                                                          //AND in Y
20:                                      .append("y", new BasicDBObject("$gt", 10).append("$lt", 90));
21:      //OR
22:                      QueryBuilder builder = QueryBuilder.start("x").is(0)
23:                              .and("y").greaterThan(10).lessThan(90);
24:                      System.out.println("\n Count");
25:                      long count = collection.count(query); // builder.get()
26:                      System.out.println(count);
27:                      System.out.println("Find One");
28:                      DBObject one = collection.findOne(query); //builder.get()
29:                      System.out.println(one);
30:                      System.out.println("\n Find All");
31:                      DBCursor cursor = collection.find(query); //builder.get()
32:                      try {
33:                          while(cursor.hasNext()) {
34:                              DBObject all = cursor.next();
35:                              System.out.println(all);
36:                          }
37:                      } finally {
38:                          cursor.close();
39:                      }
40:                      for(int i=0; i<10; i++) {
41:                          collection.insert(new BasicDBObject( "_id", i).
42:                append("start",
43:                    new BasicDBObject("x", new Random().nextInt(90) + 10)
44:                          .append("z", new Random().nextInt(90) + 10)
45:                ).append("end",
46:                  new BasicDBObject("x", new Random().nextInt(90) + 10)
47:                      .append("z", new Random().nextInt(90) + 10)
48:                  )
49:                          );
50:                      }
51:                      //QueryBuilder builder = QueryBuilder.start("start.x").greaterThan(50);
52:                      //DBCursor cursor = collection.find(builder.get(),
53:                      //    new BasicDBObject("start.x", true).append("_id", false).append("end.z", true));
54:                      DBCursor cursor = collection.find()
55:                                  .sort(new BasicDBObject("_id", -1)).skip(5).limit(3);
56:                      DBCursor cursor = collection.find()
57:                                  .sort(new BasicDBObject("start.x", -1).append("end.z",1)).skip(5).limit(3);

UPDATE
REMOVE

1:                                                  //query  
2:                      collection.update(new BasicDBObject("_id", "alice"),  
3:                              new BasicDBObject("age", 35));//update  
4:                      collection.update(new BasicDBObject("_id", "alice"),  
5:                              new BasicDBObject("gender", "Female"));//update  
6:                      //will remove the gender - Female and insert the Title Srs  
7:                      collection.update(new BasicDBObject("_id", "alice"),  
8:                              new BasicDBObject("$set" , new BasicDBObject("Title", "Srs")));//update  
9:                      //To insert, it is needed two last parameters  
10:                      collection.update(new BasicDBObject("_id", "frank"),         //to insert  
11:                              new BasicDBObject("$set" , new BasicDBObject("Title", "Sr")), true, false);//update  
12:                      collection.update(new BasicDBObject(),//every document        //to update  
13:                              new BasicDBObject("$set" , new BasicDBObject("Graduation", "Masters")), false, true);//update  
14:                      //collection.remove(new BasicDBObject());  
15:                      collection.remove(new BasicDBObject("_id", "alice"));  


- About blog
View - ftl - freemarker
controller/model java/spark.

- Home Work -
1 - db.grades.find({score:{$gte:65}}).sort( { score : 1 } ).limit(1)
2 - 124
3 - fhj837hf9376hgf93hf832jf9
- Week 3
- MongoDB Schema Design
Application-Driven Schema
. Features
Rich Documents
Pre join data for fast access
No Joing
No Constraina like MySql
Atomic operations(no transactions)
No Declared Schema

A Simple project in Grails - Portugues, LivroVisitas


Criação de um projeto/ Livro de Visitas usando Grails



Code in github/romalopes/livrovisitas

-- Criação do projeto


1:  create-project livrovisitas  



-- Criação do Controller inicial


1:  create-controller br.com.k2sistemas.Controle  

------------------------------------------------------------------
-- Implementação do Controller


1:  //ControleController.groovy  
2:  class ControleController {  
3:    def index() {   
4:          render "<h1>Inicio!</h1>"  
5:      }  
6:      def ola = {  
7:          render "<h1>Olá Pessoal da K2!</h1>"  
8:      }  
9:      def acao = {  
10:          [par1: "Hello", par2: "World!", date: new Date()]  
11:      }  
12:  }  
------------------------------------------------------------------
-- GSP chamada pelo ControlleController.acao


1:  <!-- acao.gsp -->  
2:  <!-- grails-app/views/controle -->  
3:  <html>  
4:      <body>  
5:          <p>${par1} ${par2} na data ${date}</p>  
6:      </body>  
7:  </html>  

------------------------------------------------------------------
-- Criação das classes de domínio


1:  create-domain-class br.com.k2sistemas.livroVisitas.User  
2:  create-domain-class br.com.k2sistemas.livroVisitas.Feedback  
3:  create-domain-class br.com.k2sistemas.livroVisitas.Comment  

------------------------------------------------------------------

-- Implementação das classes de domínio


1:  package br.com.k2sistemas.livroVisitas  
2:  class Feedback {  
3:   String title  
4:   String feedback  
5:   Date dateCreated // Nome predefinido pelo Grails a ser preenchido automaticamente  
6:   Date lastUpdated // Nome predefinido pelo Grails a ser preenchido automaticamente  
7:   // Relacionamento com outras classes  
8:   User user  
9:   static hasMany=[comments:Comment]  
10:   // Contrains definidas como static   
11:    static constraints = {  
12:          title(blank:false, nullable: false, size:3..80)  
13:          feedback(blank:false, nullable:false,size:3..500)  
14:          user(nullable:false)  
15:    }  
16:      String toString(){  
17:          return title;  
18:       }  
19:  }  

------------------------------------------------------------------

-- Implementação das classes de domínio


1:  package br.com.k2sistemas.livroVisitas  
2:  class User {  
3:   String name  
4:   String email  
5:   String webpage  
6:    static constraints = {  
7:          name (blank:false, nullable:false, size:3..30, matches:"[a-zA-Z1-9_]+")   
8:          email (email:true)  
9:          webpage (url:true)  
10:    }  
11:   String toString(){  
12:    return name;   
13:   }  
14:  }   
------------------------------------------------------------------

-- Implementação das classes de domínio


1:  package br.com.k2sistemas.livroVisitas  
2:  class Comment {  
3:   String comment  
4:   Date dateCreated // Nome predefinido pelo Grails a ser preenchido automaticamente  
5:   Date lastUpdated // Nome predefinido pelo Grails a ser preenchido automaticamente  
6:   User user;  
7:   // Garante que o Comment de um feedback será deletado caso o feedback seja deletado. Cascade  
8:   static belongsTo=[feedback:Feedback]  
9:    static constraints = {  
10:          comment (blank:false, nullable: false, size:5..500)  
11:          user (nullable: true) // Comments são permitidos sem User  
12:    }  
13:   String toString(){  
14:    if (comment.size()>20){  
15:     return comment.substring(0,19);  
16:    } else   
17:          return comment;   
18:     }  
19:  }   

-----------------------------------------

-- Criação dos controllers relativos às classes de domínio


1:  generate-controller br.com.k2sistemas.livroVisitas.Feedback   
2:  generate-controller br.com.k2sistemas.livroVisitas.User   
3:  generate-controller br.com.k2sistemas.livroVisitas.Comment  

-----------------------------------------

-- Scarffold stático. Modificar as classes de controle

1:   // Only change here  
2:   def scaffold = true   


-----------------------------------------

-- Criação das Views, com scaffold = false

1:  generate-views br.com.k2sistemas.livroVisitas.Feedback   
2:  generate-views br.com.k2sistemas.livroVisitas.User   
3:  generate-views br.com.k2sistemas.livroVisitas.Comment  

-----------------------------------------

-- Controllers e Views Poderiam ser geradas assim.

1:  generate-all  


-----------------------------------------

-- Mudar o DataSource para update.

-----------------------------------------

-- Autenticação

1:  create-filters security  

Create the SecurityFilters

1:  class SecurityFilters {  
2:    def filters = {  
3:      loginCheck(controller: '*', action: '*') {  
4:        before = {  
5:          if (!session.user && actionName != "login") {  
6:                redirect( controller: "controle", action: "login")  
7:            return false  
8:          }  
9:        }  
10:      }  
11:    }  
12:  }  


1:  <%--/controle/login.gsp --%>  
2:  <html>  
3:    <body>  
4:      <div class="body">  
5:        <h1>Login</h1>  
6:        <div class="message"><h3>${message}</h3></div>  
7:        <g:form action="login" method="post" >  
8:          <div class="dialog">  
9:            <table>  
10:              <tbody>  
11:                <tr class="prop">  
12:                  <td valign="top" class="name">  
13:                   <g:message code="message" default="Nome do Usuário:" />  
14:                  </td>  
15:                  <td valign="top" class="value">  
16:                    <g:textField name="username" value="${username}" />  
17:                  </td>  
18:                </tr>  
19:                <tr>  
20:                  <td>  
21:                   <g:message code="message" default="Senha: " />  
22:                  </td>  
23:                  <td valign="top" class="value ">  
24:                    <g:passwordField name="password" />  
25:                  </td>  
26:                </tr>  
27:              </tbody>  
28:            </table>  
29:          </div>  
30:          <div class="buttons">  
31:            <span class="button"><g:actionSubmit action="login" value="logado" /></span>  
32:          </div>  
33:        </g:form>  
34:      </div>  
35:    </body>  
36:  </html>  


No controleController

1:      def login() {  
2:          if(!params.username)  
3:          {  
4:              render(view: "login")  
5:              return  
6:          }  
7:          //AQUI INCLUIR TODAS AS REGRAS DE AUTENTICAÇÃO  
8:          def user = User.findByName(params.username)  
9:          if (user) {  
10:              session.user = params.username  
11:              render(view: "/index")  
12:          } else {  
13:              render(view: "login", model: [message: "Usuario ${params.username} nao encontrado"])  
14:          }  
15:      }  
16:      def logout () {  
17:          session.invalidate()  
18:          render(view: "login")  
19:      }  

UrlMappings.groovy

1:  "/"(controller: 'controle', action: 'index')  


-----------------------------------------

BootStrap


1:  class BootStrap {  
2:      def init = { servletContext ->  
3:           User user = new User(name:'anderson', email:'romalopes@romalopes.com.br', webpage:'http://www.romalopes.com.br')  
4:           if (!user.save()){  
5:               log.error "Could not save user!!"  
6:               log.error "${user.errors}"  
7:           }  
8:   }  
9:       def destroy = {  
10:       }  
11:  }  

--------------------------------------
-- Conversão e renderização de outros formatos. Inserir no ControleController.groovy

1:      def xmlList = {  
2:          render Feedback.list() as XML  
3:       }  


--------------------------------------

-- Utilização de Plugin


1:      install-plugin searchable  

-- Em cada classe de domínio que se deseja usar o searchable

1:    static searchable = true     


--------------------------------------

-- teste

1:  test-app  

--------------------------------------
-- Criação do War


1:  war  

Basics of Gradle based on User Guide

Gradle - http://www.gradle.org/docs/current/userguide/userguide_single.html#overview
Introduction
- Build Automate, test, publishing, deployiment and so on.
- Combines the flexibility of ANT with dependency management and conventions of Maven.
- Uses Groovy DSL and uses a declarative way to describe the builds.
Features
Declarative builds and build-by-convention
Gradle uses DSL(Domain Specific Language) based on Groovy.
Language for dependency based programming
The tasks are based in a hierarchy, favoring the builds
Structure your build
Easy to compose buid from reusable pieces
Deep API
Allow to monitor and customize the configuration and behavior execution
Scalability
Reusability allows one project uses parts of other projects increasing the produtivity
Multi-project builds
You can rebuild a project or its sub-project, that depends on another sub-project.
Different ways to manage dependencies
Maven has just one way. Can integrate with maven and ivy, or just use jars or directories.
Groovy
Insteady of XML.

Simple examples
- Project
Each project has many tasks
- To create a simple project, create a file build.gradle
Ex:

1:  task hello {  
2:  doLast {  
3:  println 'Hello world!'  
4:  }  
5:  }  
6:  OR  
7:  task hello << {  
8:                      println 'Hello world!'  
9:                  }  
RUN: gradle -q hello
It is possible to add behavior to an existing task

1:          task hello << {  
2:              println 'Hello Earth'  
3:          }  
4:          hello.doFirst {  
5:              println 'Hello Venus'  
6:          }  

Task Dependencies
One task can depend on another using:


1:  task taskX(dependsOn: 'taskY') << {  

Dynamic Tasks
Tasks can be dynamic. In this case, 4 tasks are created (task0 to task3). There is a dependency.

1:          4.times { counter ->  
2:  task "task$counter" << {  
3:                  println "I'm task number $counter"  
4:              }  
5:          }  
6:          task0.dependsOn task2, task3  
Default Tasks

1:  defaultTasks 'task1', 'task2'  
- Plugins
Plugin is an extension to Grails which configures a project in some way, typically adding pre-configured tasks.
Gradle with Java plugin
apply plugin: 'java'
To create a project, it is good to have the same structure that MAVEN project
PROJECT
- src
main
- java
- test
- java
- resources
- resources
buid
libs
Main Commands
gradle -->
build -> compile, test, build jar
clean -> delete the build directory
assemble -> Compile and build the jar. Does not run the tests
check -> compile and test
External dependencies
Repositories

1:  repositories {  
2:    mavenCentral()  
3:  }  
Dependencies

1:  dependencies {  
2:  compile -> dependency in compile-time  
3:  testCompile -> dependency in compile-time for test  
4:  runtime -> dependency in runtime  
5:  }  


Multi-project Java build create a file called: settings.gradle in the same directory of build.gradle.
Ex:

1:       include "shared", "api", "services:webservice", "services:shared"  
2:       rootProject.children.each { prj -> //para cada filho  
3:            prj.projectDir = new File("$rootDir/subprojects/$prj.name")  
4:       }  
5:       rootProject.name = 'groovy' // set the name of rootProject.  

Basics of Maven

- Maven
                Features and goals:
                               - Simplify the build process, sharing JARs, publishing informations in a easy way.
                               - Deploy a system
                               - Manage Documentation, dependencies, releases, distribution, report
                               - Maven works on top of ANT
                                               Ant needs you to write the logic and provide de data
                                               Maven needs you to provide the data and know how to do most things.
                               - Maven has a local repository and well named jars, docs, etc.
                                               Provide a single location for downloads which versions are created automatically
                - POM (Project Object Model)
                              
                - Create a Project
                               Simple way:
                                                - mvn archetype:generate
                                                - There are over 850 archetypes.  Use the 314(
                                                -archetype-quickstart), sugested but maven
                                                - Version of maven-archetype-quickstart: Use the sugested(1.1), number 6.
                                                - groupId: The groupId that will be inside the pom.xml. I use: br.com.romalopes.meven2Test
                                                - artifactId: mavenToGradle.  The project will be created inside this directory.
                                                - Version: Accept the sugested.
                                                - Value for property papckage: The package that will be create inside the structure:br.com.romalopes.meven2Test
                                                - Confirm
                              
                               - A more sofisticated way
                                               - mvn archetype:generate -DgroupId=br.com.romalopes.maven2Test -DartifactId=maven-test -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
                It creates a structure like that:
                - my-app
                               |-- pom.xml
                               -- src
                                               |-- main
                                               |   `-- java.
                                               |       `-- com.
                                               |           `-- mycompany-
                                               |               `-- app
                                               |                   `-- App.java
                                               |-- resources
                                                              -- META-INF
                                                              -- application.properties   -->  InputStream is = getClass().getResourceAsStream( "/test.properties" );
                                               -- test
                                                               -- java
                                                                               -- com
                                                                                              -- mycompany
                                                                                                              -- app
                                                                                                                              -- AppTest.java
                - Phases to buil a project
                               Validate
                               generate-sources
                               process-sources
                               generate-resources
                               process-resources
                               compile
                               mvn package
                               integration-test
                               verify
                               install - install into the local repository
                               deploy - copies the final package to the remote repository
                               - others
                                               clean
                                               test
                                               dependency:copy-dependencies
                                               mvn site - generate a site for project documentation
                                               can call
                                                               mvn clean dependency:copy-dependencies package
                              
                - maven to Eclipse
                               Simple java
                                               mvn eclipse:eclipse
                               Dynamic Web Project
                                               mvn eclipse:eclipse -Dwtpversion=1.5
                                               In Eclipse:
                                                               Properties->Modify Project->Change Facet
                - plugins
                               To customize the build for a Maven Project
                                               
- Example

1:          <project xmlns="http://maven.apache.org/POM/4.0.0"  
2:           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
3:           xsi:schemaLocation="http://maven.apache.org/POM/4.0.0  
4:                               http://maven.apache.org/xsd/maven-4.0.0.xsd">  
5:           <modelVersion>4.0.0</modelVersion>  
6:           <groupId>com.mycompany.app</groupId>  
7:           <artifactId>my-app</artifactId>  
8:           <version>1.0-SNAPSHOT</version>  
9:           <packaging>jar</packaging>  
10:           <name>Maven Quick Start Archetype</name>  
11:           <url>http://maven.apache.org</url>  
12:           <dependencies>  
13:              <dependency>  
14:               <groupId>junit</groupId>  
15:               <artifactId>junit</artifactId>  
16:               <version>3.8.1</version>  
17:               <scope>test</scope>  
18:              </dependency>  
19:           </dependencies>  
20:           <build>  
21:              <resources>  
22:               <resource>  
23:                  <directory>src/main/resources</directory>  
24:                  <filtering>true</filtering>  
25:               </resource>  
26:              </resources>  
27:           </build>  
28:           <properties>  
29:              <my.filter.value>hello</my.filter.value>  
30:           </properties>  
31:          </project>