gpt4 book ai didi

java - 当我尝试在 pom.xml 中指定 list 时出现格式错误的 POM

转载 作者:行者123 更新时间:2023-12-02 06:22:22 25 4
gpt4 key购买 nike

我将我的应用程序打包为

mvn package

它创建了一个jar文件名为 JasperCSVDataSource-1.0-SNAPSHOT.jar

当我尝试运行 jar 文件时:

java -jar JasperCSVDataSource-1.0-SNAPSHOT.jar

我收到一条错误消息 no main manifest attribute, in target/JasperCSVDataSource-1.0-SNAPSHOT.jar 。在创建的 JAR 中自动添加 list 文件,我更新了我的pom.xml添加以下内容:

<configuration>
<archive>
<manifest>
<mainClass>com.comp.main.CommandLineRunner</mainClass>
</manifest>
</archive>
</configuration>

完整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
http://maven.apache.org/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>
<groupId>com.comp</groupId>
<artifactId>JasperCSVDataSource</artifactId>
<version>1.0-SNAPSHOT</version>

<configuration>
<archive>
<manifest>
<mainClass>com.suhail.main.CommandLineRunner</mainClass>
</manifest>
</archive>
</configuration>

<packaging>jar</packaging>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>

<dependencies>

<dependency>
<groupId>net.sf.jasperreports</groupId>
<artifactId>jasperreports</artifactId>
<version>6.8.0</version>
</dependency>

<dependency>
<groupId>ar.com.fdvs</groupId>
<artifactId>DynamicJasper</artifactId>
<version>5.0.11</version>
</dependency>
</dependencies>

</project>

但是现在当我尝试构建文件时,我收到一条错误消息:

    [ERROR] [ERROR] Some problems were encountered while processing the POMs:
[ERROR] Malformed POM /Users/tambro/jasper-test/pom.xml: Unrecognised tag: 'configuration' (position: START_TAG seen ...</version>\n \n <configuration>... @12:20) @ /Users/tambro/jasper-test/pom.xml, line 12, column 20
@
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR] The project com.tambro:JasperCSVDataSource:1.0-SNAPSHOT (/Users/tambro/jasper-test/pom.xml) has 1 error
[ERROR] Malformed POM /Users/tambro/jasper-test/pom.xml: Unrecognised tag: 'configuration' (position: START_TAG seen ...</version>\n \n <configuration>... @12:20) @ /Users/tambro/jasper-test/pom.xml, line 12, column 20 -> [Help 2]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException
[ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/ModelParseException

我无法理解其中的原因。这不是将 list 文件添加到 jar 的正确方法吗?

最佳答案

您需要提供<configuration>带有特定 Maven 插件的标签。在这种情况下,它可能是 maven-jar-plugin所以你的pom.xml你的 <project> 里面应该有类似的东西标签

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
...
<configuration>
<archive>
<manifest>
<mainClass>com.comp.main.CommandLineRunner</mainClass>
</manifest>
</archive>
</configuration>
...
</plugin>
</plugins>
</build>

关于java - 当我尝试在 pom.xml 中指定 list 时出现格式错误的 POM,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55823765/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com