mevan pom.xml常见问题

打包依赖,同时添加主类,使用 assembly:assembly打包

   <plugins>
        <plugin>
            <artifactId>maven-assembly-plugin</artifactId>
            <configuration>
                <archive>
                    <manifest>
                        <mainClass>recommend.merge</mainClass>
                    </manifest>
                </archive>
                <descriptorRefs>
                    <descriptorRef>jar-with-dependencies</descriptorRef>
                </descriptorRefs>
            </configuration>
        </plugin>

使用package打包,同时加入依赖,指定主类

<build>
<plugins>
<plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>3.1.0</version>
                <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.ManifestResourceTransformer">
                            <mainClass>cal.hive</mainClass>
                        </transformer>
                    </transformers>
                </configuration>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
</plugins>
</build>

报错

Missing artifact jdk.tools:jdk.tools:jar:1.7

<dependency>  
    <groupId>jdk.tools</groupId>  
    <artifactId>jdk.tools</artifactId>  
    <version>1.7</version>  
    <scope>system</scope>  
    <systemPath>${JAVA_HOME}/lib/tools.jar</systemPath>  
</dependency> 

报错

java.lang.SecurityException: Invalid signature file digest for Manifest main attributes

由于某些包的重复引用,以至于打包之后的META-INF的目录下多出了一些.SF,.DSA,*.RSA文件所致
这里写图片描述

主类可以在MANIFEST.MF文件中手动添加
MANIFEST.MF文件内容
Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Built-By: Administrator
Created-By: Apache Maven 3.3.9
Build-Jdk: 1.8.0_131
Main-Class: cal.hive

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Maven是一个项目管理工具,它使用pom.xml文件来描述项目的配置和依赖关系。pom.xml是Project Object Model(项目对象模型)的缩写,它是一个XML文件,用于定义项目的结构、构建配置、依赖关系等。 在pom.xml文件中,你可以配置项目的基本信息,如项目的坐标(groupId、artifactId、version)、项目的构建方式(如编译器版本、源代码目录、资源目录等)、项目的依赖关系(其他库或模块)、插件配置等。 通过pom.xml文件,Maven可以自动下载所需的依赖库,并根据配置进行项目的构建、测试、打包等操作。它还可以帮助你管理项目的版本、发布项目到远程仓库等。 下面是一个简单的pom.xml文件的示例: ```xml <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 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.example</groupId> <artifactId>my-project</artifactId> <version>1.0.0</version> <dependencies> <!-- 添加项目的依赖库 --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-core</artifactId> <version>5.2.0.RELEASE</version> </dependency> </dependencies> <build> <!-- 配置项目的构建方式 --> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.8.1</version> <configuration> <source>1.8</source> <target>1.8</target> </configuration> </plugin> </plugins> </build> </project> ``` 这个示例中定义了一个项目的基本信息,包括groupId、artifactId和version。还定义了一个依赖库(spring-core)和一个构建插件(maven-compiler-plugin)。 通过pom.xml文件,Maven可以根据配置自动下载所需的依赖库,并使用指定的构建插件进行项目的构建。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值