美文网首页
maven打jar包可执行

maven打jar包可执行

作者: 指尖架构141319 | 来源:发表于2019-10-08 19:05 被阅读0次
    <build>
            <finalName>vehicle-status-collection</finalName>
            <plugins>
                <plugin>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <configuration>
                        <source>1.6</source>
                        <target>1.6</target>
                    </configuration>
                </plugin>
    
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-shade-plugin</artifactId>
                    <version>1.4</version>
                    <configuration>
                        <createDependencyReducedPom>false</createDependencyReducedPom>
                    </configuration>
                    <executions>
                        <execution>
                            <!-- 执行package的phase -->
                            <phase>package</phase>
                            <!-- 为这个phase绑定goal -->
                            <goals>
                                <goal>shade</goal>
                            </goals>
                            <configuration>
                                <!-- 过滤掉以下文件,不打包 :解决包重复引用导致的打包错误-->
                                <filters>
                                    <filter>
                                        <artifact>*:*</artifact>
                                        <excludes>
                                            <exclude>META-INF/*.SF</exclude>
                                            <exclude>META-INF/*.DSA</exclude>
                                            <exclude>META-INF/*.RSA</exclude>
                                        </excludes>
                                    </filter>
                                </filters>
                                <transformers>
                                    <transformer
                                            implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                                        <resource>META-INF/spring.handlers</resource>
                                    </transformer>
                                    <!-- 打成可执行的jar包 的主方法入口-->
                                    <transformer
                                            implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                        <mainClass>com.timanetworks.operate.vehicle.online.monitor.Main</mainClass>
                                    </transformer>
    
                                    <transformer
                                            implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                                        <resource>META-INF/spring.schemas</resource>
                                    </transformer>
                                </transformers>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
            <defaultGoal>compile</defaultGoal>
        </build>
    

    相关文章

      网友评论

          本文标题:maven打jar包可执行

          本文链接:https://www.haomeiwen.com/subject/dmlipctx.html