CodexBloom - Programming Q&A Platform

Maven build scenarios with 'Could not resolve dependencies' when using a custom repository in settings.xml

👀 Views: 0 💬 Answers: 1 📅 Created: 2025-06-14
maven dependencies repository settings.xml Java

I've searched everywhere and can't find a clear answer. I'm relatively new to this, so bear with me. I'm prototyping a solution and I've searched everywhere and can't find a clear answer... This might be a silly question, but After trying multiple solutions online, I still can't figure this out. I'm working with an scenario with my Maven build where it fails to resolve dependencies from a custom repository defined in my `settings.xml`. My `pom.xml` looks like this: ```xml <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.example</groupId> <artifactId>my-app</artifactId> <version>1.0-SNAPSHOT</version> <dependencies> <dependency> <groupId>com.example.lib</groupId> <artifactId>custom-lib</artifactId> <version>2.0.0</version> </dependency> </dependencies> </project> ``` And my `settings.xml` is set up as follows: ```xml <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"> <profiles> <profile> <id>custom-repo</id> <repositories> <repository> <id>my-custom-repo</id> <url>https://my.custom.repo/repo</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </repository> </repositories> </profile> </profiles> <activeProfiles> <activeProfile>custom-repo</activeProfile> </activeProfiles> </settings> ``` When I run `mvn clean install`, I keep getting the following behavior: ``` [behavior] Failed to execute goal on project my-app: Could not resolve dependencies for project com.example:my-app:jar:1.0-SNAPSHOT: Could not find artifact com.example.lib:custom-lib:jar:2.0.0 in my-custom-repo (https://my.custom.repo/repo) -> [Help 1] ``` I have verified that the artifact `custom-lib` version `2.0.0` is indeed present in the specified repository, and I even tried to access the URL directly through a web browser, which works fine. I’ve also tried skipping the local repository by setting `-U` to force update, but the question continues. My Maven version is 3.8.6. Any insights into what could be going wrong here or additional troubleshooting steps I could take to resolve this dependency scenario? My development environment is Linux. Any ideas what could be causing this? I'm working on a web app that needs to handle this. Has anyone else encountered this? I'm working on a web app that needs to handle this. Any help would be greatly appreciated! Thanks for any help you can provide! This is happening in both development and production on Linux. What's the correct way to implement this? I'm working in a Debian environment. Has anyone dealt with something similar?