发布于

maven项目引用本地当前目录的lib包


<build>
        <plugins>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.6.0</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                    <encoding>UTF-8</encoding>
                    <compilerArguments>
                        <extdirs>${project.basedir}/lib</extdirs>
                    </compilerArguments>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy-dependencies</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${project.build.directory}/lib</outputDirectory>
                            <overWriteReleases>false</overWriteReleases>
                            <overWriteSnapshots>false</overWriteSnapshots>
                            <overWriteIfNewer>true</overWriteIfNewer>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <artifactId>maven-resources-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy-resources</id>
                        <phase>package</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <resources>
                                <!--把配置文件打包到指定路径-->
                                <resource>
                                    <directory>src/main/resources/</directory>
                                    <includes>
                                        <include>**/*.*</include>
                                    </includes>
                                </resource>
                            </resources>
                            <outputDirectory>${project.build.directory}/config</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <configuration>
                    <!--不打入jar包的文件类型或者路径-->
                    <!--<includes>-->
                        <!--<include>com/**</include>-->
                    <!--</includes>-->
                    <archive>
                        <manifest>
                            <!-- 执行的主程序路径 -->
                            <mainClass>com.yozo.fcscloud.provider.web.cmc.FcscloudApplication</mainClass>
                            <!--是否要把第三方jar放到manifest的classpath中-->
                            <addClasspath>true</addClasspath>
                            <!--生成的manifest中classpath的前缀,因为要把第三方jar放到lib目录下,所以classpath的前缀是lib/-->
                            <classpathPrefix>lib/</classpathPrefix>
                            <!-- 打包时 MANIFEST.MF 文件不记录的时间戳版本 -->
                            <useUniqueVersions>false</useUniqueVersions>
                        </manifest>
                        <manifestEntries>
                            <!-- 在 Class-Path 下添加配置文件的路径 -->
                            <Class-Path>config/</Class-Path>
                        </manifestEntries>
                    </archive>
                </configuration>
            </plugin>
            <!--<plugin>-->
               <!--<groupId>org.apache.maven.plugins</groupId>-->
               <!--<artifactId>maven-assembly-plugin</artifactId>-->
               <!--<executions>-->
                  <!--<execution>&lt;!&ndash; 配置执行器 &ndash;&gt;-->
                    <!--<id>make-assembly</id>-->
                    <!--<phase>package</phase>&lt;!&ndash; 绑定到package生命周期阶段上 &ndash;&gt;-->
                    <!--<goals>-->
                         <!--<goal>single</goal>&lt;!&ndash; 只运行一次 &ndash;&gt;-->
                    <!--</goals>-->
                    <!--<configuration>-->
                        <!--<finalName>${project.name}</finalName>-->
                        <!--<descriptor>src/main/assembly/assembly.xml</descriptor>&lt;!&ndash;配置描述文件路径&ndash;&gt;-->
                    <!--</configuration>-->
                  <!--</execution>-->
               <!--</executions>-->
            <!--</plugin>-->

        </plugins>
    </build>
评论