一、背景
下午在调试nexus的时候,其他同事不小心把匿名访问停用了,导致客户端android打包的时候,报错: Received status code 401 from server: Unauthorized。
![](https://img-blog.csdnimg.cn/direct/f7cb474012ae45c5af1261f951ffba23.png)
这显然不符合我们的需求,在打包的时候,应该是可以匿名访问的。(只有上传jar包的时候,才会要求用户名+密码)
二、开启匿名访问
- 禁用匿名访问
![](https://img-blog.csdnimg.cn/direct/a92c161d70824a5bb807f83001a795e0.png)
- 开启匿名访问
![](https://img-blog.csdnimg.cn/direct/9e92dcd2e5014c9484f008594e02bbac.png)
勾选:"Allow anonymous users to access the server",意思是允许匿名用户访问nexus服务器。
Realm 选择默认的Local Authenticating Realm即可。
![](https://img-blog.csdnimg.cn/direct/66ad23ce7df4442f8a6b7353db94418c.png)
RealmsManage
the active security realms and their order
![](https://img-blog.csdnimg.cn/direct/37d12cebe3224d778ecba4087c718871.png)
三、总结
开启匿名访问后,再次访问maven-metadata.xml,不再让我们输入用户名和密码了。
这时,android打包成功,不再报错401未授权Unauthorized了。