[ERROR] Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.1.1:war

30151 단어
스프링부트 프로젝트를 만들고 스프링부트를 도입하지 않을 때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.0modelVersion>
<groupId>com.examplegroupId>
<artifactId>demo-without-parentartifactId>
<version>0.0.1-SNAPSHOTversion>
<packaging>warpackaging>

    <name>demo-without-parentname>
    <description>Demo project for Spring Bootdescription>

    <properties>
        <java.version>1.8java.version>
        <project.build.sourceEncoding>UTF-8project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8project.reporting.outputEncoding>
        <maven.compiler.encoding>UTF-8maven.compiler.encoding>
    properties>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.bootgroupId>
                <artifactId>spring-boot-dependenciesartifactId>
                <version>2.0.2.RELEASEversion>
                <type>pomtype>
                <scope>importscope>
            dependency>
        dependencies>
    dependencyManagement>

    <dependencies>
        <dependency>
            <groupId>org.springframework.bootgroupId>
            <artifactId>spring-boot-starter-webartifactId>
        dependency>

        <dependency>
            <groupId>org.springframework.bootgroupId>
            <artifactId>spring-boot-starter-tomcatartifactId>
            <scope>providedscope>
        dependency>
        <dependency>
            <groupId>org.springframework.bootgroupId>
            <artifactId>spring-boot-starter-testartifactId>
            <scope>testscope>
        dependency>
    dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.bootgroupId>
                <artifactId>spring-boot-maven-pluginartifactId>
            plugin>
        plugins>
    build>

project>

 
실행
mvn clean install 

콘솔 오류 보고:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.1.1:war

원인:war로 설정되었을 때 웹.xml이 있어야 합니다.
해결: 플러그인 구성 속성을 통해 무시할 수 있습니다.
우선spring-boot-dependencies 이pom 파일을 찾아서
<maven-war-plugin.version>3.1.0maven-war-plugin.version>

버전 번호는 3.1.0입니다.
그리고 프로젝트의pom.xml에 추가
<plugin>
    <artifactId>maven-war-pluginartifactId>
    <version>3.1.0version>
plugin>

버전 번호는spring-boot-dependencies의maven-war-plugin-version 버전 번호와 일치해야 합니다.
mvn clean install을 다시 실행하여 포장에 성공했음을 알립니다.
아이디어에서 시작 클래스를 실행하고 성공적으로 시작합니다.하지만
java -jar demo-without-parent-0.0.1-SNAPSHOT.war

 :demo-without-parent-0.0.1-SNAPSHOT.war 

왜냐하면,maven-war-plugin이 실행되었지만,spring-boot-maven-plugin 플러그인은 실행되지 않았습니다. 이 플러그인은 버전을 지정하지 않았기 때문에 버전 번호를 설정합니다. 여전히spring-boot-dependencies에서 대응하는 버전 번호를 찾습니다:2.0.2.RELEASE
<plugin>
    <groupId>org.springframework.bootgroupId>
    <artifactId>spring-boot-maven-pluginartifactId>
    <version>2.0.2.RELEASEversion>
    <executions>
        <execution>
            <goals>
                <goal>repackagegoal>
            goals>
        execution>
    executions>
plugin>

재실행
mvn clean install ,
mvn clean install
java -jar demo-without-parent-0.0.1-SNAPSHOT.war

성공하다.
마지막 요약:
1)、maven-war-plugin :
    2.2: WEB-INF web.xml
    3.1.0: web.xml
     , spring-boot-dependencies maven-war-plugin 。

2)、spring-boot-maven-plugin repackage, spring boot  , 。

3)、 spring-boot-dependencies

 
첨부, 완전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.0modelVersion>
<groupId>com.examplegroupId>
<artifactId>demo-without-parentartifactId>
<version>0.0.1-SNAPSHOTversion>
<packaging>warpackaging>

    <name>demo-without-parentname>
    <description>Demo project for Spring Bootdescription>

    <properties>
        <java.version>1.8java.version>
        <project.build.sourceEncoding>UTF-8project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8project.reporting.outputEncoding>
        <maven.compiler.encoding>UTF-8maven.compiler.encoding>
    properties>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.bootgroupId>
                <artifactId>spring-boot-dependenciesartifactId>
                <version>2.0.2.RELEASEversion>
                <type>pomtype>
                <scope>importscope>
            dependency>
        dependencies>
    dependencyManagement>

    <dependencies>
        <dependency>
            <groupId>org.springframework.bootgroupId>
            <artifactId>spring-boot-starter-webartifactId>
        dependency>

        <dependency>
            <groupId>org.springframework.bootgroupId>
            <artifactId>spring-boot-starter-tomcatartifactId>
            <scope>providedscope>
        dependency>
        <dependency>
            <groupId>org.springframework.bootgroupId>
            <artifactId>spring-boot-starter-testartifactId>
            <scope>testscope>
        dependency>
    dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.bootgroupId>
                <artifactId>spring-boot-maven-pluginartifactId>
                <version>2.0.2.RELEASEversion>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackagegoal>
                        goals>
                    execution>
                executions>
            plugin>
            <plugin>
                <artifactId>maven-war-pluginartifactId>
                <version>3.1.0version>
            plugin>
        plugins>
    build>

project>

좋은 웹페이지 즐겨찾기