Maven not downloading jars behind proxy

2019-02-28 09:28发布

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.

1条回答
小情绪 Triste *
2楼-- · 2019-02-28 09:51

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

查看更多
登录 后发表回答