【发布时间】:2014-04-24 14:49:17
【问题描述】:
我的 /users//settings.xml 中有以下配置。
在插件组下:
<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
用户名和密码正确。我手动验证了它。还有什么可能是错的? 谷歌搜索没有多大帮助。
编辑:来自日志的更多详细信息。
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
如何冲洗?
【问题讨论】:
-
您确定用户名/密码不应该是tomcat/tomcat?这是典型的设置:
<user name="tomcat" password="tomcat" roles="admin-gui,manager-gui" />。三重检查您的 tomcat-users.xml。添加用户后是否重启过Tomcat? -
它并没有说登录名/密码不正确。它说您无权访问您请求的资源
-
@jedison 是的,我确实检查了几次。我改变了u / p。所以是的,我上面发布的那个是正确的。
-
@hoaz 还有什么要调查的吗?
-
你访问什么网址?
标签: java maven tomcat deployment unauthorized