maven将依赖依赖打包到jar中

         通过maven-assembly-plugin插件可以实现将依赖jar包打包到自己的jar包中的需求,只需要在pom.xml中配置该插件即可,配置如下:

  <build>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>  
                <configuration>  
                    <source>1.7</source>  
                    <target>1.7</target>  
                    <encoding>${project.build.sourceEncoding}</encoding>  
                </configuration>  
            </plugin>
            <plugin>
               <artifactId>maven-assembly-plugin</artifactId>
                <configuration>
                  <descriptorRefs>
                    <descriptorRef>jar-with-dependencies</descriptorRef>
                  </descriptorRefs>
                  <archive>  
                        <manifest>  
                            <mainClass>com.test.Helloworld</mainClass>
                        </manifest>
                   </archive>
                </configuration>
                <executions>
                  <execution>
                    <id>make-assembly</id> <!-- this is used for inheritance merges -->
                    <phase>package</phase> <!-- bind to the packaging phase -->
                    <goals>
                      <goal>single</goal>
                    </goals>
                  </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

 

posted @ 2018-07-16 15:12  wavemelody  阅读(212)  评论(0编辑  收藏  举报