개요 

사용자가 template 으로부터 maven project를 생성할 수 있게 해주는 plugin 입니다. 미리 정의된 maven project template 는 archetype 이라고 불립니다.


Goals

Goals

다음 세 개의 goal이 있습니다.

goal namedescription
archetype:generatecreates a Maven project from an archetype: asks the user to choose an archetype from the archetype catalog, and retrieves it from the remote repository. Once retrieved, it is processed to create a working Maven project.
archetype:create-from-project

creates an archetype from an existing project.

archetype:crawl 

search a repository for archetypes and updates a catalog.


Archetype List

maven repository 에 bundle 된 archetype list 입니다.

http://maven.apache.org/archetype/maven-archetype-bundles/


Archetype ArtifactIdsDescription
maven-archetype-archetypeAn archetype which contains a sample archetype.
maven-archetype-j2ee-simpleAn archetype which contains a simplifed sample J2EE application.
maven-archetype-mojo (deprecated)Deprecated in favour of maven-archetype-plugin, which has a better name.
maven-archetype-pluginAn archetype which contains a sample Maven plugin.
maven-archetype-plugin-siteAn archetype which contains a sample Maven plugin site.
maven-archetype-portletAn archetype which contains a sample JSR-268 Portlet.
maven-archetype-quickstartAn archetype which contains a sample Maven project.
maven-archetype-simpleAn archetype which contains a simple Maven project.
maven-archetype-siteAn archetype which contains a sample Maven site which demonstrates some of the supported document types like APT, XDoc, and FML and demonstrates how to i18n your site.
maven-archetype-site-simpleAn archetype which contains a sample Maven site.
maven-archetype-webappAn archetype which contains a sample Maven Webapp project.


Project 생성

batch mode

기본적으로 interactive mode 이나 다음과 같이 batch mode 로 프로젝트를 생성할 수 있습니다.

mvn archetype:generate -B -DarchetypeGroupId=org.apache.maven.archetypes -DarchetypeArtifactId=maven-archetype-quickstart  -DgroupId=com.company -DartifactId=project -Dversion=1.0 -Dpackage=1.5
BASH


유용한 Archetype

simple webapp 

아주 간단한 웹 app

mvn archetype:generate -DgroupId=com.example.app -DartifactId=my-webapp -DarchetypeArtifactId=maven-archetype-webapp
CODE


Spring webapp 

  1. webapp project 생성

    mvn archetype:generate -B -DarchetypeGroupId=org.apache.maven.archetypes -DarchetypeArtifactId=maven-archetype-webapp  -DgroupId=com.company -DartifactId=myproject -Dversion=1.0-SNAPSHOT
    BASH
  2. maven 을 eclipse 프로젝트로 변경

    cd myproject
    mvn eclipse:eclipse -Dwtpversion=2.0
    BASH
  3. eclipse 에서 import -> maven project 선택

simple java project

  1. java project 생성

    mvn archetype:generate -B -DarchetypeGroupId=org.apache.maven.archetypes -DarchetypeArtifactId=maven-archetype-quickstart -DgroupId=com.company -DartifactId=myproject -Dversion=1.0-SNAPSHOT
    BASH

spring archetype on google code

  • Everything is configured using Spring 3
  • Hibernate 3.5 is used for persistence in Hypersonic in-memory db (HSQLDB)
  • Base class for CRUD-operations
  • Base class for unit tests and simple integration test
  • Sitemesh configured as jsp layout manager
  • Configured embedded jetty server
  1. source checkout
    1. svn checkout http://spring-archetypes.googlecode.com/svn/trunk/ spring-archetypes-read-only
  2. local repository 에 위 archetype 을 설치하기 위해 다음 명령 실행
    1. mvn install
  3. project 생성

    mvn -B archetype:generate -DarchetypeCatalog=local -DarchetypeGroupId=org.springframework.archetypes -DarchetypeArtifactId=spring-3-mvc-archetype  -groupId=com.company -DartifactId=my-test-spring-3-mvc-project -Dversion=0.1-SNAPSHOT
    CODE

     

Spring MVC 3.2 Quickstart  on github

Generated project characteristics

  • No-xml Spring MVC 3.2 web application for Servlet 3.0 environment
  • Thymeleaf, Bootstrap
  • JPA 2.0 (Hibernate/HSQLDB/Spring Data JPA)
  • MongoDB (Spring Data Mongo)
  • JUnit/Mockito
  • Spring Security 3.1


  1. clone

    git clone git@github.com:kolorobot/spring-mvc-quickstart-archetype.git 
    CODE
  2. install

    mvn install
    CODE
  3. project create (-DgroupId와 , -DartifactId, -Dversion 항목 수정)

    mvn archetype:generate \
            -DarchetypeGroupId=pl.codeleak \
            -DarchetypeArtifactId=spring-mvc-quickstart \
            -DarchetypeVersion=1.0.1 \
            -DgroupId=my.groupid \
            -DartifactId=my-artifactId \
            -Dversion=version \
            -DarchetypeRepository=http://kolorobot.github.io/spring-mvc-quickstart-archetype
    CODE
  4. run

    mvn tomcat7:run
    CODE


같이 보기


Ref