构建工具——maven的补充

  1.安装jar到本地仓库

    有时候有部分jar由于在maven的中央仓库,只能引用本地的,可以将jar安装到本地仓库进行操作(请先确保mvn命令可以正常运行)

mvn install:install-file -Dfile=D:BdiduYunDownloadBlogsrcmainwebappWEB-INFlibueditor-1.1.2.jar -DgroupId=com.java1234 -DartifactId=ueditor -Dversion=1.1.2 -Dpackaging=jar

     各参数含义:

      -Dfile:JAR包文件所在的路径

      -DgroupId、-DartifactId、-Dversion:指定坐标信息。 

      -Dpackaging:打包方式

  2.引用本地的jar(项目中的jar)

    参考http://blog.csdn.net/hhb200766/article/details/42168819

    补充:使用systemPath是deprecated(来自stackoverflow回答)

  

  3.更改编译版本(在pom.xml中的build节点添加如下信息)

<plugins>  
        <plugin>  
                <groupId>org.apache.maven.plugins</groupId>  
                <artifactId>maven-compiler-plugin</artifactId>  
                <version>3.0</version>  
                <configuration>  
                   <source>1.8</source>  
                   <target>1.8</target>  
                </configuration>  
        </plugin>  
    </plugins> 

     4.maven的父子工程的搭建

      待补充,暂时可参考:https://www.cnblogs.com/java-zhao/archive/2016/01/06/5107569.html

    5.IDEA中打包jar包

    

   打包时包含第三方依赖的方法:

  

<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>com.cloume</groupId>
<artifactId>project</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>

<name>App</name>
<url>http://maven.apache.org</url>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>3.8.1</version>
        <scope>test</scope>
    </dependency>
</dependencies>
<build>
  <plugins>
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-shade-plugin</artifactId>
        <version>1.2.1</version>
        <executions>
            <execution>
                <phase>package</phase>
                <goals>
                        <goal>shade</goal>
                </goals>
                    <configuration>
                        <transformers>
                            <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                <mainClass>com.cloume.project.App</mainClass>
                            </transformer>
                        </transformers>
                    </configuration>
            </execution>
        </executions>
     </plugin>
  </plugins>
</build>

    https://blog.csdn.net/yangguosb/article/details/80619481

    https://blog.csdn.net/xb12369/article/details/79966633

原文地址:https://www.cnblogs.com/jiangbei/p/7637719.html