You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Sonatype Nexus 3中PostgreSQL数据库错误导致API认证及个人令牌查看失败

问题描述

新创建的本地用户或获得Nexus访问权限的LDAP用户无法登录仓库,也无法查看个人令牌。nexus.log中记录的错误信息如下:

Error updating database.  Cause: org.postgresql.util.PSQLException: ERROR: there is no unique or exclusion constraint matching the ON CONFLICT specification
### The error may exist in org/sonatype/nexus/internal/security/apikey/ApiKeyDAO.xml
### The error may involve org.sonatype.nexus.internal.security.apikey.ApiKeyDAO.save-Inline
### The error occurred while setting parameters
### SQL: INSERT INTO api_key (primary_principal, domain, token, principals , created )         VALUES (?,                 ?, ?, ? , ? )     ON CONFLICT (primary_principal, domain, principals) DO UPDATE SET         token = ?, principals = ?,          created = ? ;
### Cause: org.postgresql.util.PSQLException: ERROR: there is no unique or exclusion constraint matching the ON CONFLICT specification'; mapped from: org.sonatype.nexus.datastore.api.DataAccessException:
### Error updating database.  Cause: org.postgresql.util.PSQLException: ERROR: there is no unique or exclusion constraint matching the ON CONFLICT specification
### The error may exist in org/sonatype/nexus/internal/security/apikey/ApiKeyDAO.xml
### The error may involve org.sonatype.nexus.internal.security.apikey.ApiKeyDAO.save-Inline
### The error occurred while setting parameters
解决步骤
  • 停止Nexus服务,避免操作数据库时产生冲突
  • 使用PostgreSQL客户端(如psql)连接到Nexus对应的数据库实例
  • 切换至Nexus使用的数据库(替换为实际数据库名):
    \c nexus_database
    
  • 为api_key表添加指定的唯一约束:
    ALTER TABLE api_key ADD CONSTRAINT api_key_unique_constraint UNIQUE (primary_principal, domain, principals);
    
  • 启动Nexus服务,测试用户登录及个人令牌查看功能,确认问题解决

内容的提问来源于stack exchange,提问作者Gabriella Turek

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.22 03:12:36