使用maven创建多模块web项目

使用maven创建多模块web项目

1. 模块说明
 wudemo-common(通用工具包)
 wudemo-dal(数据库访问层)
 wudemo-model(实体POJO)
 wudemo-core(业务核心)
 wudemo-web(web)
 
2. 进入wudemo目录,maven命令新建各个子模块
 

  1. mvn archetype:create -DgroupId=net.welken -DartifactId=wudemo-common -DpackageName=net.welken.wudemo.common  
  2.   
  3. mvn archetype:create -DgroupId=net.welken -DartifactId=wudemo-core -DpackageName=net.welken.wudemo.core  
  4.   
  5. mvn archetype:create -DgroupId=net.welken -DartifactId=wudemo-model -DpackageName=net.welken.wudemo.model  
  6.   
  7. mvn archetype:create -DgroupId=net.welken -DartifactId=wudemo-dal -DpackageName=net.welken.wudemo.dal   
  8.   
  9. mvn archetype:create -DgroupId=net.welken -DartifactId=wudemo-web -DpackageName=net.welken.wudemo.web -DarchetypeArtifactId=maven-archetype-webapp  

3. 在wudemo根目录下新建一个 pom.xml 配置文件
总pom.xml文件中,以下节点需注意:

  1. < groupId > net.welken </ groupId >   
  2. < artifactId > wudemo-parent </ artifactId >   
  3. < packaging > pom </ packaging >   
  4. < name > wudemo Parent Project </ name >   
  5. < version > 1.0-SNAPSHOT </ version >   
  6.   
  7. < modules >   
  8.     < module > wudemo-common </ module >   
  9.     < module > wudemo-model </ module >   
  10.     < module > wudemo-core </ module >   
  11.     < module > wudemo-dal </ module >   
  12.     < module > wudemo-web </ module >   
  13. </ modules >   

 
 
4. 各个子pom.xml文件,添加parent节点

  1. < parent >    
  2.     < artifactId > wudemo-parent </ artifactId >    
  3.     < groupId > net.welken </ groupId >    
  4.     < version > 1.0-SNAPSHOT </ version >    
  5. </ parent >   
  


5. 各个子pom.xml文件,添加依赖管理dependencies节点

  1. < dependencies >   
  2.     < dependency >   
  3.         < groupId > junit </ groupId >   
  4.         < artifactId > junit </ artifactId >   
  5.         < version > 3.8.1 </ version >   
  6.         < scope > test </ scope >   
  7.     </ dependency >   
  8.      
  9.     < dependency >   
  10.         < groupId > net.welken </ groupId >   
  11.         < artifactId > wudemo-common </ artifactId >   
  12.     </ dependency >   
  13.     < dependency >   
  14.         < groupId > net.welken </ groupId >   
  15.         < artifactId > wudemo-dal </ artifactId >   
  16.     </ dependency >   
  17.     < dependency >   
  18.         < groupId > net.welken </ groupId >   
  19.         < artifactId > wudemo-core </ artifactId >   
  20.     </ dependency >   
  21.     < dependency >   
  22.         < groupId > net.welken </ groupId >   
  23.         < artifactId > wudemo-model </ artifactId >   
  24.     </ dependency >   
  25. </ dependencies >  

猜你喜欢

转载自babyduncan.iteye.com/blog/1336086