maven--package
Posted chbyiming
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了maven--package相关的知识,希望对你有一定的参考价值。
<build> <resources> <resource> <directory>src/main/resources</directory> <targetPath>${project.build.directory}/config</targetPath> </resource> <!--编译的时候,类路径下也复制一份配置文件(防止开发启动的时候读取不到配置的情况)--> <resource> <directory>src/main/resources</directory> <targetPath>${project.build.directory}/classes</targetPath> </resource> </resources> <plugins> <!-- 将所依赖的第三方jar包打入target下的lib目录 --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <version>2.5</version> <executions> <execution> <id>copy-dependencies</id> <phase>package</phase> <goals> <goal>copy-dependencies</goal> </goals> <configuration> <outputDirectory>${project.build.directory}/lib</outputDirectory> </configuration> </execution> </executions> </plugin> <!-- 解决资源文件的编码问题 --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-resources-plugin</artifactId> <configuration> <encoding>UTF-8</encoding> </configuration> </plugin> <!-- 打jar包的main方法配置 --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <configuration> <archive> <manifest> <addClasspath>true</addClasspath> <classpathPrefix>lib/</classpathPrefix> <mainClass>主程序路径</mainClass> </manifest> <!-- 给清单文件添加键值对(配置文件外置) --> <manifestEntries> <Class-Path>config/</Class-Path> </manifestEntries> </archive> <!--打包的时候忽略classes 路径下的配置文件 --> <excludes> <exclude>*.properties</exclude> <exclude>*.xml</exclude> <exclude>*.txt</exclude> <exclude>templates/**</exclude> </excludes> </configuration> </plugin> </plugins> </build>
以上是关于maven--package的主要内容,如果未能解决你的问题,请参考以下文章
在eclipse中,maven项目在Run As中找不到maven package是怎么回事?
maven package install deploy区别