zoukankan      html  css  js  c++  java
  • maven 项目打包不包含META_INF maven 的方法

    maven 生成的jar 包不包含META_INF maven 的目的很简单,就是不打算暴露太多的关于maven profile 配置(可能会有敏感信息)

    解决方法

    参考自己的实际项目以及使用的构建方式添加addMavenDescriptor为false 的配置
    以下是一个spring boot 的项目的参考配置
    pom.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0</modelVersion>
        <parent>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-parent</artifactId>
            <version>2.2.10.RELEASE</version>
            <relativePath/> <!-- lookup parent from repository -->
        </parent>
        <groupId>com.dalong</groupId>
        <artifactId>prome</artifactId>
        <version>0.0.1-SNAPSHOT</version>
        <name>prome</name>
        <description>Demo project for Spring Boot</description>
        <properties>
            <java.version>1.8</java.version>
        </properties>
        <dependencies>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-actuator</artifactId>
            </dependency>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-web</artifactId>
            </dependency>
            <dependency>
                <groupId>io.micrometer</groupId>
                <artifactId>micrometer-registry-prometheus</artifactId>
                <scope>runtime</scope>
            </dependency>
            <dependency>
                <groupId>org.aspectj</groupId>
                <artifactId>aspectjweaver</artifactId>
                <version>1.8.6</version>
            </dependency>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-test</artifactId>
                <scope>test</scope>
                <exclusions>
                    <exclusion>
                        <groupId>org.junit.vintage</groupId>
                        <artifactId>junit-vintage-engine</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
        </dependencies>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-maven-plugin</artifactId>
                </plugin>
                 // 因为使用了spring boot 的flat jar 模式,所以对于maven-jar-plugin 插件,配置addMavenDescriptor false
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-jar-plugin</artifactId>
                    <version>2.6</version>
                    <configuration>
                        <archive>
                            <addMavenDescriptor>false</addMavenDescriptor>
                        </archive>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    </project>
    • 效果

    参考资料

    https://maven.apache.org/guides/mini/guide-archive-configuration.html

  • 相关阅读:
    linux之shell综合例子之定时任务
    linux之shell流程控制
    C#之抛异常
    C# 日期帮助类
    Aspose Excel 单元格合并后边框显示不全
    Microsoft Compatibility telemetry占cpu资源高
    js 获取年、月、周、当前日期第几周、这月有那几周
    JS 延迟加载
    EasyUI DataGrid 多级表头设置
    C#关于日期 月 天数 和一年有多少周及根据某年某周获取时间段的计算
  • 原文地址:https://www.cnblogs.com/rongfengliang/p/13753895.html
Copyright © 2011-2022 走看看