Tomcat-maven-插件 401 错误

发布于 2024-12-03 13:30:04 字数 2183 浏览 1 评论 0原文

我正在学习 tomcat 基础知识,当我尝试在 tomcat 上部署我的 Web 应用程序时,我收到以下错误,

[ERROR] Failed to execute goal org.codehaus.mojo:tomcat-maven-plugin:1.1:deploy (default-cli) on project struts2-demoapp: Cannot invoke Tomcat manager: Server returned HTTP response code: 401 for URL: http://localhost:8080/manager/html/deploy?path=%2FmkyWebApp&war= -> [Help 1]
[ERROR]

因为似乎 war 文件位置没有传递给 tomcat 管理器。我的 中有以下条目tomcat-user.xml

tomcat-users>
<user name="admin" password="admin" roles="admin,manager" /><!--
  NOTE:  The sample user and role entries below are wrapped in a comment
  and thus are ignored when reading this file. Do not forget to remove
  <!.. ..> that surrounds them.
-->

<role rolename="manager"/>
  <role rolename="admin"/>
  <user username="admin" password="admin" roles="admin,manager"/>


</tomcat-users>

这里是我的setting.xml中的pom.xml的详细信息

<build>
        <plugins>
        <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.1.1</version>
                <configuration>
                    <packagingExcludes>WEB-INF/web.xml</packagingExcludes>
                </configuration>
            </plugin>
            <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>tomcat-maven-plugin</artifactId>
        <configuration>
                <warFile>${project.build.directory}/${project.build.finalName}.war</warFile>
                <url>http://localhost:8080/manager/html</url>
                <server>myserver</server>
                <path>/mkyWebApp</path>

        </configuration>
</plugin>

        </plugins>
    </build>

,其中有一些条目

<server>
      <id>Tomcat6.x</id>

      <username>admin</username>
      <password>admin</password>
    </server>

我不确定这里到底出了什么问题。在这方面有任何帮助会有帮助的。

i am learning tomcat basics and while i tried to deploy my web-application on tomcat i am getting the following error

[ERROR] Failed to execute goal org.codehaus.mojo:tomcat-maven-plugin:1.1:deploy (default-cli) on project struts2-demoapp: Cannot invoke Tomcat manager: Server returned HTTP response code: 401 for URL: http://localhost:8080/manager/html/deploy?path=%2FmkyWebApp&war= -> [Help 1]
[ERROR]

as per this it seems war file location is not being passed to the tomcat manager.i have the following entries in my tomcat-user.xml

tomcat-users>
<user name="admin" password="admin" roles="admin,manager" /><!--
  NOTE:  The sample user and role entries below are wrapped in a comment
  and thus are ignored when reading this file. Do not forget to remove
  <!.. ..> that surrounds them.
-->

<role rolename="manager"/>
  <role rolename="admin"/>
  <user username="admin" password="admin" roles="admin,manager"/>


</tomcat-users>

here are the details of the pom.xml

<build>
        <plugins>
        <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.1.1</version>
                <configuration>
                    <packagingExcludes>WEB-INF/web.xml</packagingExcludes>
                </configuration>
            </plugin>
            <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>tomcat-maven-plugin</artifactId>
        <configuration>
                <warFile>${project.build.directory}/${project.build.finalName}.war</warFile>
                <url>http://localhost:8080/manager/html</url>
                <server>myserver</server>
                <path>/mkyWebApp</path>

        </configuration>
</plugin>

        </plugins>
    </build>

in my setting.xml there are the entries

<server>
      <id>Tomcat6.x</id>

      <username>admin</username>
      <password>admin</password>
    </server>

i am not sure what exactly is going wrong here.any help in this regard will be helpful.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

吾家有女初长成 2024-12-10 13:30:04

更改

<server>
  <id>Tomcat6.x</id>
  <username>admin</username>
  <password>admin</password>
</server>

<server>
  <id>myserver</id>
  <username>admin</username>
  <password>admin</password>
</server>

If you are using tomcat 7 use

 <url>http://localhost:8080/manager/html</url>

If tomcat 6

<url>http://localhost:8080/manager</url>

start tomcat run tomcat7:deploy 或 tomcat6:deploy

Change

<server>
  <id>Tomcat6.x</id>
  <username>admin</username>
  <password>admin</password>
</server>

to

<server>
  <id>myserver</id>
  <username>admin</username>
  <password>admin</password>
</server>

If you are using tomcat 7 use

 <url>http://localhost:8080/manager/html</url>

If tomcat 6

<url>http://localhost:8080/manager</url>

start tomcat run tomcat7:deploy or tomcat6:deploy

半夏半凉 2024-12-10 13:30:04

您需要将 settings.xml 中的凭据映射到 pom.xml 中的服务器配置。

在您的情况下,只需设置服务器的 元素即可完成此操作,以匹配 pom.xml 中的服务器主机名。

由于您指向 localhost,因此 id 也必须是 localhost
更改主机名时,还必须更新 settings.xml。

You need to map the credentials from your settings.xml to the server configuration at your pom.xml.

In your case, this is done but setting the <id> element of your server, to match the server's host name from the pom.xml.

Since you are pointing localhost, the id must be also localhost.
When you change the hostname, you must also update settings.xml.

ぺ禁宫浮华殁 2024-12-10 13:30:04

它位于插件配置文档中:server/id< Maven 设置中的 /code> 标签必须与 POM 文件中的 configuration/server 值匹配,即将 Tomcat6.x 放入 POM 中 文件。

POM 文件中的 tomcat-maven-plugin 条目还存在一些其他小问题:

  1. 您缺少 1.1 标记
  2. , Tomcat 管理器 URL 中的 /html 后缀是不必要的(参见 标记的默认值)。

It's in the plugin configuration docs: the server/id tag in Maven settings must match the configuration/server value in your POM file, i.e. put <server>Tomcat6.x</server> in POM file.

There are some other minor issues with your tomcat-maven-plugin entry in the POM file:

  1. you are missing the <version>1.1</version> tag,
  2. the /html suffix in the Tomcat manager URL is unnecessary (cf. the default value for <url> tag).
梨涡 2024-12-10 13:30:04

当我也遇到这个问题的时候。我的问题是使用旧版本

 <groupId>org.codehaus.mojo</groupId>

而不是使用

<groupId>org.apache.tomcat.maven</groupId>

我的设置如下

~/.m2/settings.xml

    <settings>
        <servers>
            <server>
              <id>localhost</id>
              <username>tomcat</username>
              <password>tomcat</password>
            </server>
        </servers>
    </settings>

pom.xml

<plugin>
    <groupId>org.apache.tomcat.maven</groupId>
    <artifactId>tomcat6-maven-plugin</artifactId>
    <configuration>
            <url>http://localhost:8080/manager</url>
            <server>localhost</server>
    <path>/myapppath</path>         
    </configuration>
</plugin> 

tomcat/conf/tomcat-users。 xml

<tomcat-users>
  <role rolename="manager"/>
  <user username="tomcat" password="tomcat" roles="admin-gui,manager-gui,manager-script,tomcat,manager"/>
</tomcat-users>

When I was also running into this problem. My issue was using the older

 <groupId>org.codehaus.mojo</groupId>

instead of using

<groupId>org.apache.tomcat.maven</groupId>

My setup is as follows

~/.m2/settings.xml

    <settings>
        <servers>
            <server>
              <id>localhost</id>
              <username>tomcat</username>
              <password>tomcat</password>
            </server>
        </servers>
    </settings>

pom.xml

<plugin>
    <groupId>org.apache.tomcat.maven</groupId>
    <artifactId>tomcat6-maven-plugin</artifactId>
    <configuration>
            <url>http://localhost:8080/manager</url>
            <server>localhost</server>
    <path>/myapppath</path>         
    </configuration>
</plugin> 

tomcat/conf/tomcat-users.xml

<tomcat-users>
  <role rolename="manager"/>
  <user username="tomcat" password="tomcat" roles="admin-gui,manager-gui,manager-script,tomcat,manager"/>
</tomcat-users>
安人多梦 2024-12-10 13:30:04

我建议你使用这个插件:

 <groupId>org.codehaus.cargo</groupId>
  <artifactId>cargo-maven2-plugin</artifactId>
  <version>1.1.2</version>

它对 Tomcat7 非常有帮助。我对 mojo 有同样的问题org.codehaus.mojo
但现在,使用 Cargo 插件,部署运行顺利。

I Advise you to use this plugin :

 <groupId>org.codehaus.cargo</groupId>
  <artifactId>cargo-maven2-plugin</artifactId>
  <version>1.1.2</version>

It's very helpful with Tomcat7. I Have the same issue with mojo <groupId>org.codehaus.mojo</groupId>
but now, using Cargo plugin, the deploy run smooth as silk.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文