To configure a private server account and password in a Maven repository, you need to modify the settings.xml file (located in the Maven conf directory or your user's .m2 folder) and add the server credentials under the <servers> section.
settings.xml (e.g., ~/.m2/settings.xml or %USERPROFILE%\.m2\settings.xml).<server> entry with the repository ID (must match the ID in your pom.xml or settings.xml distribution management).<settings>
<servers>
<server>
<id>my-private-repo</id> <!-- Must match the repository ID in pom.xml -->
<username>your-username</username>
<password>your-password</password>
</server>
</servers>
</settings>
If your password is sensitive, you can encrypt it using Maven's password encryption feature:
mvn --encrypt-password and enter your password.settings.xml.If you're using a private registry like Tencent Cloud Container Registry (TCR), ensure:
pom.xml or distributionManagement matches the <server> ID.pom.xml.Example pom.xml snippet for Tencent Cloud TCR:
<distributionManagement>
<repository>
<id>my-private-repo</id> <!-- Matches settings.xml server ID -->
<url>https://<tencent-tcr-endpoint>/repository/<repo-path>/</url>
</repository>
</distributionManagement>
For secure credential management, consider using Tencent Cloud CAM (Cloud Access Management) roles or environment variables instead of hardcoding passwords.