Maven 多模块

使用 Maven 构建多模块项目

  • 进入helloweb项目根目录,删除target目录
  • 新建4个文件夹 helloweb-core && helloweb-entity && helloweb-parent && helloweb-web
  • 将pom.xml 和 src 复制,分别放到4个目录中 && 删除src,修改pom.xml && 新建modules目录,将4个文件夹都放进去
    
    <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.0modelVersion>
        <groupId>com.coder352groupId>
        <artifactId>hellowebartifactId>
        <version>1.0-SNAPSHOTversion>
        <packaging>pompackaging>  
        <name>hellowebname>
        <modules>
            <module>modules/helloweb-parentmodule>  
            <module>modules/helloweb-entitymodule>
            <module>modules/helloweb-coremodule>
            <module>modules/helloweb-webmodule>
        modules>
    project>
  • 导入Eclipse
  • 修改helloweb-parent的pom.xml 文件,将packing改为pom,core和entity改为jar,web不用改
  • 修改core,web,entity的pom.xml && 在groupId标签上面添加parent
    <parent>
        <groupId>com.coder352groupId>
        <artifactId>helloweb-parentartifactId>
        <version>1.0version>
        <relativePath>relativePath>
    parent>
  • 修改四个pom.xml的artifactId,改为对应的-web -entity -parent -core
  • 删除项目,重新导入

你可能感兴趣的:(Java)