错误:无法执行目标org.apache.maven.plugins:maven-deploy-plugin:2.8.2:deploy 405,

时间:2019-05-02 17:20:15

标签: java maven tomcat

使用maven,我希望将所有依赖项都本地部署到tomcat服务器。
但是我遇到了一些错误。我使用安装在“ / opt”目录中的操作系统archlinux和tomcat。

Java版本:“ 11.0.2” 2019年1月15日LTS
Maven版本:3.0.6
Tomcat版本:9.0.17

<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
            <servers>
                <server>
                    <id>TomcatServer</id>
                    <username>onur</username>
                    <password>onur123</password>
                </server>
            </servers>

    <profiles>
        <profile>
            <properties>
                    <tomcathome>/opt/apache-tomcat-9.0.17</tomcathome>
            </properties>
            <repositories>
                <repository>
                    <id>DefaultRepo</id>
                    <url>http://localhost:8080/estech</url>
                    <releases>
                        <enabled>false</enabled>
                    </releases>
                </repository>
            </repositories>
        </profile>
    </profiles>

</settings>

这是我的pom.xml。我使用maven deploy插件将其部署到tomcat服务器。
如何解决此问题?

<?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.pmyo.group5</groupId>
    <artifactId>estech</artifactId>
    <version>1.0</version>
    <packaging>war</packaging>
    <distributionManagement>
        <repository>
            <id>DefaultRepo</id>
            <name>localhost</name>
            <url>http://localhost:8080/estech/</url>
        </repository> 
    </distributionManagement>

    <name>estech Maven Webapp</name>  
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.7</maven.compiler.source>
        <maven.compiler.target>1.7</maven.compiler.target>
    </properties>

    <dependencies>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>4.0.1</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet.jsp</groupId>
            <artifactId>javax.servlet.jsp-api</artifactId>
            <version>2.3.3</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
        </dependency>
        <dependency>
            <groupId>org.mariadb.jdbc</groupId>
            <artifactId>mariadb-java-client</artifactId>
            <version>2.4.1</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.11</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>2.6</version>
        </dependency>

    </dependencies>

    <build>

        <finalName>estech</finalName>

            <plugins>
                <plugin>
                    <artifactId>maven-clean-plugin</artifactId>
                    <version>3.1.0</version>
                </plugin>
                <plugin>
                    <artifactId>maven-resources-plugin</artifactId>
                    <version>3.0.2</version>
                </plugin>
                <plugin>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.8.0</version>
                </plugin>

                <plugin>
                    <artifactId>maven-war-plugin</artifactId>
                    <version>3.2.2</version>
                    <configuration>
                          <failOnMissingWebXml>false</failOnMissingWebXml>
                    </configuration>
                </plugin>
                <plugin>
                    <artifactId>maven-install-plugin</artifactId>
                    <version>2.5.2</version>
                </plugin>
                <plugin>
                    <artifactId>maven-deploy-plugin</artifactId>
                    <version>2.8.2</version>
                    <executions>
                        <execution>
                            <id>default-deploy</id>
                            <phase>deploy</phase>
                            <goals>
                                <goal>deploy</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>

            </plugins>
        </pluginManagement>
        <plugins>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
            </plugin>

        </plugins>
    </build>
</project>

错误:

[INFO] Scanning for projects...
[INFO] 
[INFO] -----------------------< com.pmyo.group5:estech >-----------------------
[INFO] Building estech Maven Webapp 1.0
[INFO] --------------------------------[ war ]---------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:3.1.0:clean (default-clean) @ estech ---
[INFO] Deleting /home/onur/IdeaProjects/Es-tech/estech/target
[INFO] 
[INFO] --- maven-resources-plugin:3.0.2:resources (default-resources) @ estech ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/onur/IdeaProjects/Es-tech/estech/src/main/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.8.0:compile (default-compile) @ estech ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 21 source files to /home/onur/IdeaProjects/Es-tech/estech/target/classes
[INFO] /home/onur/IdeaProjects/Es-tech/estech/src/main/java/Models/ProductComments.java: Some input files use or override a deprecated API.
[INFO] /home/onur/IdeaProjects/Es-tech/estech/src/main/java/Models/ProductComments.java: Recompile with -Xlint:deprecation for details.
[INFO] 
[INFO] --- maven-resources-plugin:3.0.2:testResources (default-testResources) @ estech ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/onur/IdeaProjects/Es-tech/estech/src/test/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.8.0:testCompile (default-testCompile) @ estech ---
[INFO] No sources to compile
[INFO] 
[INFO] --- maven-surefire-plugin:2.22.1:test (default-test) @ estech ---
[INFO] No tests to run.
[INFO] 
[INFO] --- maven-war-plugin:3.2.2:war (default-war) @ estech ---
[INFO] Packaging webapp
[INFO] Assembling webapp [estech] in [/home/onur/IdeaProjects/Es-tech/estech/target/estech]
[INFO] Processing war project
[INFO] Copying webapp resources [/home/onur/IdeaProjects/Es-tech/estech/src/main/webapp]
[INFO] Webapp assembled in [152 msecs]
[INFO] Building war: /home/onur/IdeaProjects/Es-tech/estech/target/estech.war
[INFO] 
[INFO] --- maven-deploy-plugin:2.8.2:deploy (default-cli) @ estech ---
Uploading to DefaultRepo: http://localhost:8080/estech/com/pmyo/group5/estech/1.0/estech-1.0.war
Uploading to DefaultRepo: http://localhost:8080/estech/com/pmyo/group5/estech/1.0/estech-1.0.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  6.847 s
[INFO] Finished at: 2019-05-02T19:48:25+03:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.8.2:deploy (default-cli) on project estech: Failed to deploy artifacts: Could not transfer artifact com.pmyo.group5:estech:war:1.0 from/to DefaultRepo (http://localhost:8080/estech/): Failed to transfer file http://localhost:8080/estech/com/pmyo/group5/estech/1.0/estech-1.0.war with status code 405 -> [Help 1]
[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/MojoExecutionException

1 个答案:

答案 0 :(得分:0)

maven-deploy-plugin不适用于将WAR部署到Tomcat中。它用于将构建工件转移到存储库中。

您应该看看tomcat-maven-plugincargo-maven-plugin