zoukankan      html  css  js  c++  java
  • 使用Idea创建多Module工程

    1. 点击 New -- Project

    2. 设置工程父Pom, 如下

    <?xml version="1.0" encoding="UTF-8"?>
    <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.0</modelVersion>
    
        <groupId>org.test</groupId>
        <artifactId>test-parent</artifactId>
        <version>1.0.0.Beta</version>
    
        <dependencies>
            <dependency>
                <groupId>com.google.guava</groupId>
                <artifactId>guava</artifactId>
                <version>15.0</version>
            </dependency>
        </dependencies>
    </project>

    3. 删除父工程Src并创建子Module, 点击 New -- Module

    4. 将子module的java和resource目录设置为source目录

    右击java和resource目录, 选择 Mark Directory As -- Source Root

    5. 用子module的pom继承父module的pom, 这样就能使用父module的dependencies了

    pom如下

    <?xml version="1.0" encoding="UTF-8"?>
    <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">
        <parent>
            <artifactId>test-parent</artifactId>
            <groupId>org.test</groupId>
            <version>1.0.0.Beta</version>
        </parent>
        <modelVersion>4.0.0</modelVersion>
    
        <artifactId>sub-module</artifactId>
    
    
    </project>

    6.  在子module的dependency中加入所有pom里引入的依赖(如果开启了Auto-Import denpendency, 则不需要这一步)

    右击子module, 选择 Open Module Setting

    点右边的+号,选择Library

    添加需要的Jar

    7. 开始在子Module写代码吧!

  • 相关阅读:
    hdu1418 欧拉公式
    hdu1215七夕节 筛选法求公因子和
    hdu1215 The area
    hdu1005Number Sequence
    hdu1021 数学题 并不是说难,而是数学题那种简单朴素的思想get不到
    Mongo第三个参数的用法
    js 显示刚刚上传的图片 (onchange事件)
    在linux中安装memcache服务器
    jQuery 倒计时
    PHP获取文章发布时间
  • 原文地址:https://www.cnblogs.com/zemliu/p/3378396.html
Copyright © 2011-2022 走看看