2

Maven is unable to download jar (s) (Dependency) behind proxy.

Here is my pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<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.faizan.firstbootapp.group1</groupId>
<artifactId>com-faizan-firstbootapp-group-1</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>FirstBootApp</name>
<description>Test app for Maven build system</description>

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.0.2.RELEASE</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <java.version>1.8</java.version>
</properties>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

    <dependency>
        <groupId>com.h2database</groupId>
        <artifactId>h2</artifactId>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-tomcat</artifactId>
    </dependency>
    <dependency>
        <groupId>org.apache.tomcat.embed</groupId>
        <artifactId>tomcat-embed-jasper</artifactId>
    </dependency>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>jstl</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-thymeleaf</artifactId>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>

</project>

Here is my settings.xml at path C:\Users\faizanmubasher\.m2\settings.xml. I have added proxies in it.

<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
                      https://maven.apache.org/xsd/settings-1.0.0.xsd">
 <proxies>
  <proxy>
    <id>skm--http-proxy</id>
    <active>true</active>
    <protocol>http</protocol>
    <host>my.proxy.ip.here</host>
    <port>8080</port>
    <username>faizanmubasher</username>
    <password>*****</password>
  </proxy>
  <proxy>
    <id>skm--https-proxy</id>
    <active>true</active>
    <protocol>https</protocol>
    <host>my.proxy.ip.here</host>
    <port>8080</port>
    <username>faizanmubasher</username>
    <password>*****</password>
  </proxy>
 </proxies>
</settings>

Username and password are correct.

Is it due to my office's proxy that is not allowing to download jar or is it some Maven settings that I need to configure?

I am facing this error on STS IDE.

The container 'Maven Dependencies' references non existing library 'C:\Users\faizanmubasher\.m2\repository\org\springframework\boot\spring-boot-autoconfigure\2.0.2.RELEASE\spring-boot-autoconfigure-2.0.2.RELEASE.jar'    FirstBootApp        Build path  Build Path Problem

My Maven version is Apache Maven 3.5.3.

EDIT

The command set MAVEN_OPTS="-DhttpProxyHost=xxx.xx.xx.xx -DsocksProxyPort=8080" doesn't work as well.

Faizan Mubasher
  • 4,427
  • 11
  • 45
  • 81
  • couple of things. in your proxy setting, are you sure it is https? secondly. Instead of changing in .m2/setting.xml try changing it in settings.xml under /etc/maven or whereever maven is installed – pvpkiran Jun 20 '18 at 08:17
  • Not working. I have changed in both `settings.xml` files. – Faizan Mubasher Jun 20 '18 at 08:39
  • are you sure `C:\Users\faizanmubasher\.m2\settings.xml` path. execute `mvn -version` + check in apache-maven-3.5.0\conf\settings.xml check your `M2_HOME` + your `MAVEN_HOME` – Stéphane GRILLON Jun 20 '18 at 10:01
  • can you curl your proxy with the provided data? thats my first default check... – U.V. Jan 22 '19 at 15:24

2 Answers2

1

Try this, if 1 does not work try 2, then 3:

1) First update the project, Alt-F5

2) Then go to your repo and blow away the directory for that dependency which should be in the directory C:\Users\faizanmubasher.m2\repository\org\springframework\boot\spring-boot-autoconfigure\2.0.2.RELEASE Then do an Alt-F5 again.

3) If this fails try a mvn clean install -U from the command line.

You can test your maven to maven central repo connectivity with the following command:

mvn archetype:generate

You should see over 2000 archetypes returned

Essex Boy
  • 7,565
  • 2
  • 21
  • 24
0
  • I have encountered the same problem.
  • And I turned back to older versions of maven which is 3.1.0.
  • I was trying to use a http proxy to get reached to maven https repository.

    Here, there is a issue for newer versions in maven's jira.
    https://issues.apache.org/jira/browse/PROXY-27

gurbux
  • 29
  • 8