美文网首页
Maven 3.5创建项目

Maven 3.5创建项目

作者: xiang205012 | 来源:发表于2017-12-21 20:26 被阅读17次

       我们在开发2个以上模块的时候,每个模块都是一个Maven Project。比如搜索平台,学习平台,考试平台。开发的时候可以自己管自己独立编译,测试,运行。但如果想要将他们整合起来,我们就需要一个聚合工程。

创建聚合工程

1513428776(1).png

创建模块

1513428917(1).png
1513429126(1).png
1513429212(1).png
1513429362(1).png
1513429479(1).png

给模块添加jar,使用maven的方式,但坐标方式有时是找不到需要的jar就会出错:

       Missing artifact net.sourceforge:pinyin4j:jar:2.5.0
解决办法,从网络下载该jar包然后在cmd窗口使用 maven命令打入仓库中。

mvn install:install-file -Dfile=F:\Maven\LocalRepository\pinyin4j-2.5.0.jar -DgroupId=net.sourceforge.pinyin4j -DartifactId=pinyin4j -Dversion=2.5.0 -Dpackaging=jar  -DgeneratePom=true -DcreateChecksum=true

mvn install:install-file -Dfile=F:\Maven\LocalRepository\ojdbc6.jar -DgroupId=com.oracle.ojdbc6 -DartifactId=ojdbc6 -Dversion=11.2.0.1.0 -Dpackaging=jar  -DgeneratePom=true -DcreateChecksum=true
  

    mvn install:install-file   
    -Dfile=jar包的位置   
    -DgroupId=上面的groupId   
    -DartifactId=上面的artifactId   
    -Dversion=上面的version   
    -Dpackaging=jar  
然后在pom.xml中引入:
    <dependency>
            <groupId>net.sourceforge.pinyin4j</groupId>
            <artifactId>pinyin4j</artifactId>
            <version>2.5.0</version>
        </dependency>

在聚合工程的pom.xml中:

  <!-- 设定子模块的目录,目录中要有pom.xml,使用相对路径 -->
  <modules>
    <module>spring-mybatis</module>
    <module>yyptutil</module>
    <module>yyptProject</module>
  </modules>

在子模块工程的pom.xml中:

<parent>
    <groupId>yypt</groupId>
    <artifactId>yyptParent</artifactId>
    <version>0.0.1-SNAPSHOT</version>
  </parent>
  <artifactId>yyptutil</artifactId>

最后从CMD窗口进入到聚合工程的目录执行mvn install命令就可以将各个子模块工程合并到一起打成war包。

相关文章

网友评论

      本文标题:Maven 3.5创建项目

      本文链接:https://www.haomeiwen.com/subject/zldewxtx.html