发生了一个错误,在使用Maven打包Spring Boot应用程序时。

huangapple go评论72阅读模式
英文:

Occurred an error while packaging spring-boot application by maven

问题

以下是您要求的翻译内容:

The IDEA应用程序告诉我,在打包我的easy-start spring-boot应用程序时,出现了以下错误:Invalid packaging for parent POM org.springframework.boot:spring-boot-starter-web:1.5.9.RELEASE,必须是“pom”,但实际是“jar”。如何解决这个问题?
我的操作系统是macOS 10.15.7,安装了三个JDK(1.8、11、14),我正在使用maven-3.6.3,我的maven设置也已更改为JDK 1.8和11。
以下是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>org.example</groupId>
    <artifactId>SpringBoot-01-HelloWorld</artifactId>
    <version>1.0</version>

    <packaging>pom</packaging>

    <parent>
        <artifactId>spring-boot-starter-web</artifactId>
        <groupId>org.springframework.boot</groupId>
        <version>1.5.9.RELEASE</version>
    </parent>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
</project>
英文:

The IDEA app told me that Invalid packaging for parent POM org.springframework.boot:spring-boot-starter-web:1.5.9.RELEASE, must be &quot;pom&quot; but is &quot;jar&quot; while I packaged my easy-start spring-boot application, how to solve this problem?
My platform is macOS 10.15.7 with 3 JDKs(1.8, 11, 14), and I am using maven-3.6.3, my maven settings are also changed the JDK to 1.8 and 11
The pom.xml file is as followed:

&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot;
         xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
         xsi:schemaLocation=&quot;http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd&quot;&gt;
    &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;

    &lt;groupId&gt;org.example&lt;/groupId&gt;
    &lt;artifactId&gt;SpringBoot-01-HelloWorld&lt;/artifactId&gt;
    &lt;version&gt;1.0&lt;/version&gt;

    &lt;packaging&gt;pom&lt;/packaging&gt;

    &lt;parent&gt;
        &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;
        &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
        &lt;version&gt;1.5.9.RELEASE&lt;/version&gt;
    &lt;/parent&gt;

    &lt;dependencies&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
            &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;
        &lt;/dependency&gt;
    &lt;/dependencies&gt;

    &lt;build&gt;
        &lt;plugins&gt;
            &lt;plugin&gt;
                &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
                &lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt;
            &lt;/plugin&gt;
        &lt;/plugins&gt;
    &lt;/build&gt;


&lt;/project&gt;

答案1

得分: 1

以下是您要翻译的内容:

父 POM 应该是 Spring Boot 的父项目

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.5.9.RELEASE</version>
</parent>
英文:

The parent POM should be the Spring Boot parent project

&lt;parent&gt;
	&lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
	&lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt;
	&lt;version&gt;1.5.9.RELEASE&lt;/version&gt;
&lt;/parent&gt;

huangapple
  • 本文由 发表于 2020年10月15日 19:32:09
  • 转载请务必保留本文链接:https://go.coder-hub.com/64370660.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定