临海观潮

个人编程、项目管理经验、感想。

博客园 首页 新随笔 联系 订阅 管理


Mysn is created as a mutiple module project. It is devided to mysn-model-core,mysn-dao-core,mysn-service-core,and mysn-web-core module.This article will show you how to create a multiple module project with maven and eclipse.

System environment

Create the mysn project

  1. Set up a new eclipse workspace called mysn. I set the newly created workspace to "F:\myfile\mysn".
  2. add the M2_REPO classpath by executing the following command:
    mvn -Declipse.workspace=F:\myfile\mysn eclipse:add-maven-repo
  3. Open the command line shell and change to the newly created workspace directory.
  4. Create a new maven project using the archetype plugin.Execute the following command in command line shell:
    mvn archetype:create -DgroupId=cn.org.mysn -DartifactId=mysn
  5. Create a new simple project mysn inside the mysn workspace with eclipse (From the menu bar, select File >New >Project. Select Simple >Project). Eclipse will create a simple .project-file for your mysn project and you should be able to see the pom.xml-file.
  6. Delete the src-folder and open the pom.xml-file to change the packaging of your parent project to pom
    <packaging>pom</packaging>

  7. Inside the workspace directory and create some modules.
  8. cd mysn
    mvn archetype:create -DgroupId=cn.org.mysn.model.core -DartifactId=mysn-model-core
    mvn archetype:create -DgroupId=cn.org.mysn.dao.core -DartifactId=mysn-dao-core
    mvn archetype:create -DgroupId=cn.org.mysn.service.core -DartifactId=mysn-service-core
    mvn archetype:create -DgroupId=cn.org.mysn.web.core -DartifactId=mysn-web-core
    -DarchetypeArtifactId=maven-archetype-webapp

    Note: the mysn-web-core module is created as a webapp project.

  9. Add the newly created modules to your parent pom.
  10. <modules>
    <module>../mysn-model-core</module>
    <module>../mysn-dao-core</module>
    <module>../mysn-service-core</module>
    <module>../mysn-web-core</module>
    </modules>
  11. Add the parent to the POMs of the new modules:
  12. <parent>
    <groupId>cn.org.mysn</groupId>
    <artifactId>mysn</artifactId>
    <version>1.0-SNAPSHOT</version>
    </parent>
  13. Add dependency from module1 to the mysn-dao-core:
  14. <dependency>
    <groupId>cn.org.mysn.model.core</groupId>
    <artifactId>mysn-model-core</artifactId>
    <version>1.0-SNAPSHOT</version>
    </dependency>
  15. Add dependency from module1 to the mysn-service-core:
  16. <dependency>
    <groupId>cn.org.mysn.dao.core</groupId>
    <artifactId>mysn-dao-core</artifactId>
    <version>1.0-SNAPSHOT</version>
    </dependency>
  17. Add dependency from module1 to the mysn-web-core:
  18. <dependency>
    <groupId>cn.org.mysn.service.core</groupId>
    <artifactId>mysn-service-core</artifactId>
    <version>1.0-SNAPSHOT</version>
    </dependency>
  19. Install the project in your local repository and generate the eclipse files:
  20. mvn install
    mvn eclipse:eclipse
  21. Open the command line shell and change to the mysn-web-core module directory.generate the eclipse file for mysn-web-core module.
    mvn -Dwtpversion=1.0 eclipse:eclipse 

reference

posted on 2006-02-16 14:06  书生无用  阅读(554)  评论(0编辑  收藏  举报