maven 让spring resource下META-INF下文件打包到META-INF下

 

 

 

 

pom.xml buid 部分内容。
<build>
    <finalName>test</finalName>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
       
        <plugin>
            <groupId>org.apache.maven.pl
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 8
    评论
如果你使用 Maven 或 Gradle 构建你的 Spring Boot 项目,可以将外部引入的 jar打包到 fat jar 里面。下面是两个常用的方法: ### Maven 在 pom.xml 文件中,使用 `maven-shade-plugin` 插件可以将所有依赖打包为一个可执行的 fat jar。在插件配置中,使用 `include` 指定需要打包jar 包,使用 `mainClass` 指定启动类。 ```xml <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-shade-plugin</artifactId> <version>3.2.4</version> <configuration> <createDependencyReducedPom>false</createDependencyReducedPom> <filters> <filter> <artifact>*:*</artifact> <excludes> <exclude>META-INF/*.SF</exclude> <exclude>META-INF/*.DSA</exclude> <exclude>META-INF/*.RSA</exclude> </excludes> </filter> </filters> <finalName>${project.artifactId}-${project.version}</finalName> <transformers> <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> <manifestEntries> <Main-Class>com.example.Application</Main-Class> </manifestEntries> </transformer> </transformers> <artifactSet> <includes> <include>com.example:external-lib:jar:1.0.0</include> </includes> </artifactSet> </configuration> <executions> <execution> <phase>package</phase> <goals> <goal>shade</goal> </goals> </execution> </executions> </plugin> </plugins> </build> ``` ### Gradle 在 build.gradle 文件中,使用 `shadow` 插件可以将所有依赖打包为一个可执行的 fat jar。在插件配置中,使用 `include` 指定需要打包jar 包,使用 `mainClassName` 指定启动类。 ```groovy plugins { id 'com.github.johnrengelman.shadow' version '7.0.0' } shadowJar { exclude 'META-INF/*.SF' exclude 'META-INF/*.DSA' exclude 'META-INF/*.RSA' baseName = "${rootProject.name}-${project.name}" classifier = null mainClassName = 'com.example.Application' mergeServiceFiles { include 'META-INF/services/*' } configurations = [project.configurations.compile] } dependencies { implementation 'com.example:external-lib:1.0.0' } ``` 以上是两个常用的方法,可以根据自己的需要进行选择。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 8
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值