maven打包成jar, 包括依赖其他的jar

来源:互联网 发布:广联达市政预算软件 编辑:程序博客网 时间:2024/06/02 15:17

   maven打包的时候不会自动把依赖的项目打成jar放在项目中,如果需把管理的jar放在target/lib目录下,可以在pom.xml添加:

<plugin>                <groupId>org.apache.maven.plugins</groupId>                <artifactId>maven-jar-plugin</artifactId>                <configuration>                    <archive>                        <manifest>                            <addClasspath>true</addClasspath>                            <classpathPrefix>lib/</classpathPrefix>                            <mainClass>com.myhexin.main.Main</mainClass>                        </manifest>                        <manifestEntries>     <Class-Path>.</Class-Path>    </manifestEntries>                      </archive>                </configuration>            </plugin>            <plugin>                <groupId>org.apache.maven.plugins</groupId>                <artifactId>maven-dependency-plugin</artifactId>                <executions>                    <execution>                        <id>copy</id>                        <phase>install</phase>                        <goals>                            <goal>copy-dependencies</goal>                        </goals>                        <configuration>                            <outputDirectory>                                target/lib                            </outputDirectory>                        </configuration>                    </execution>                </executions>            </plugin>



0 1
原创粉丝点击