Tomcat / Maven插件 - 未经授权的错误

时间:2014-04-24 14:49:18

标签: java maven tomcat deployment unauthorized

我的/users//settings.xml中有以下配置。

在PluginsGroup下:

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

在服务器下:

  <server>
     <id>localhost</id>
     <username>tom</username>
     <password>cat</password>
   </server>

在个人资料下:

 <plugin>
   <configuration>
     <server>localhost</server>
     <url>http://localhost:8080/manager/text</url>
     <path>/</path>
   </configuration>
 </plugin>

我使用-X选项运行maven命令,我看到以下内容:

[DEBUG] Reading global settings from C:\Tools\apache-maven-3.1.1\bin\..\conf\settings.xml
[DEBUG] Reading user settings from C:\Users\<user>\.m2\settings.xml

我在tomcat用户xml文件中有manager-script个角色。

当我通过浏览器手动验证访问权限时,它可以正常工作。但是当我运行mvn tomcat7:deploy时,我得到以下内容:

 Receiving response: HTTP/1.1 401 Unauthorized

用户名和密码正确无误。我手动验证了它。还有什么可能是错的? 谷歌搜索没有多大帮助。

编辑:Log中的更多详细信息。

 HTTP/1.1 401 Unauthorized
 Server: Apache-Coyote/1.1
 Cache-Control: private
 Expires: Wed, 31 Dec 1969 18:00:00 CST
 WWW-Authenticate: Basic realm="Tomcat Manager Application"
 Set-Cookie: JSESSIONID=7320C7326C51E8F7FF9F4D23A39E6971; Path=/manager/; HttpOnly
 Content-Type: text/html;charset=ISO-8859-1
 Transfer-Encoding: chunked
 Date: Thu, 24 Apr 2014 02:56:27 GMT
 Cookie accepted: "[version: 0][name: JSESSIONID][value: 7320C7326C51E8F7FF9F4D23A39E6971]     
                           [domain: localhost][path: /manager/][expiry: null]". 
 Connection can be kept alive indefinitely
 Authentication required
 localhost:8080 requested authentication
 Authorization challenge processed
 Authentication failed
 Clearing cached auth scheme for http://localhost:8080

修改    嗯,这就是我发现的。当我从mvn命令传递用户名和密码时,它工作正常。但它没有从settings.xml中获取。

响铃吗?我也尝试将配置文件移动到MAVEN_HOME / config / settings.xml。 (删除了用户settings.xml)。但仍然是一样的。

任何设置缓存?

编辑:

我用-X打开了调试器。即使我删除了/user/.m2/settings.xml,它也会读取该文件。

[DEBUG] Reading global settings from C:\Tools\apache-maven-3.1.1\bin\..\conf\settings.xml
[DEBUG] Reading user settings from C:\Users\<user>\.m2\settings.xml

如何冲洗?

1 个答案:

答案 0 :(得分:0)

插入配置应该是这样的:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>tomcat-maven-plugin</artifactId>
    <version>1.0</version>
    <configuration>
        <server>text</server>
        <url>http://localhost:8080/manager/text</url>
    </configuration>
</plugin>

这应该有效 我猜您要部署的应用程序名为 text 。如果不是用您的Web应用程序名称替换文本。 此外,我会尝试删除最后一个<path>/</path>元素,看看这是否有帮助......