0

I have red lines in my POM file even after followed below solutions.

<modelVersion>4.0.0</modelVersion>
<groupId>tek</groupId>
<artifactId>rest</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>rest</name>
<url>http://maven.apache.org</url>
<dependencies>
    <dependency>
        <groupId>com.github.tomakehurst</groupId>
        <artifactId>wiremock</artifactId>
        <version>2.24.1</version>
    </dependency>
<dependency>
    <groupId>org.junit.jupiter</groupId>
    <artifactId>junit-jupiter-engine</artifactId>
    <version>5.5.2</version>
</dependency>

<dependency>
    <groupId>io.rest-assured</groupId>
    <artifactId>rest-assured</artifactId>
    <version>4.1.1</version>
</dependency>

Solutions here

I noticed below in my IDE. Is that something I should worry about?

enter image description here

Error when run in command line

[ERROR] Plugin org.apache.maven.plugins:maven-resources-plugin:2.5 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-resources-plugin:jar:2.5: Could not transfer artifact org.apache.maven.plugins:maven-resources-plugin:pom:2.5 from/to central (http://repo.maven.apache.org/maven2): repo.maven.apache.org: Unknown host repo.maven.apache.org -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginResolutionException

Further, when I tried to open the pom.xml directly as a project I get notification pop-up in intellij Non-managed pom.xml file found: Not sure this is related. After set the POM.xml as Maven Project. Then back to same red lines there in the POM.

Is there other alternative way of adding those dependency manually if automatic import doesn't work?

Setting.xml

enter image description here

Shabar
  • 2,617
  • 11
  • 57
  • 98
  • If you build the project with `mvn clean verify`, does it work? If not, what errors appear on the command line? – J Fabian Meier Jan 22 '20 at 13:44
  • @JFMeier I added the error to the question. `mvn clean verify` gives the same error in command line. – Shabar Jan 22 '20 at 23:02
  • 1
    Hm, `https` has been enforced lately across nearly all if not all maven repos. Does your `settings.xml` in the `.m2` directory have an `http` URL? If you visit the `http` version of `https://repo.maven.apache.org/maven2/` it'll throw a 501 – Darren Forsythe Jan 22 '20 at 23:18
  • @DarrenForsythe I added repository section into the question. I don't have `http` version there. Neither `https://repo.maven.apache.org/maven2/`. Does that mean I need to have maven rul's there under repository section in `setting.xml` file? As you can see the `POM.xml` in the question I have url with `http:`. Does that cause the issue? – Shabar Jan 22 '20 at 23:38
  • Ignoring IntelliJ for now. From a CLI, with mvn on the classpath can you try running the `mvn verify -X`, `-x` adds debug output and might let us find where the issue is. Also unknown host, is a strange one... – Darren Forsythe Jan 22 '20 at 23:54
  • The error "Unknown host repo.maven.apache.org" is certainly concerning. Does your machine have access to the Internet? – SiKing Jan 22 '20 at 23:55
  • @Darren Forsythe with more debug `ERROR] Plugin org.apache.maven.plugins:maven-resources-plugin:2.5 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-resources-plugin:jar:2.5: Could not transfer artifact org.apache.maven.plugins:maven-resources-plugin:pom:2.5 from/to central (http://repo.maven.apache.org/maven2): Failed to transfer file: http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-resources-plugin/2.5/maven-resources-plugin-2.5.pom. Return code is: 501, ReasonPhrase: HTTPS Required. -> [Help 1] ` – Shabar Jan 23 '20 at 00:09
  • @SiKing After switching to my private network it gives above error. – Shabar Jan 23 '20 at 00:11
  • there's something causing the `http` instead of `https` connections to the apache maven repo. If outside if a private network it works you might have to work with your org to find what is causing it. Could try to ensure you don't have any `http` repos set on your end, but seems unlikely if its not in your `pom` or `settings.xml`. – Darren Forsythe Jan 23 '20 at 00:20
  • @DarrenForsythe As mentioned in the above logs, even switch to private network I get `501`. So where should I check whether I have `http` repos? – Shabar Jan 23 '20 at 00:26
  • Oh sorry, assumed private was your companies VPN or similar. See https://maven.apache.org/guides/introduction/introduction-to-repositories.html `downloading from a Remote repository`. – Darren Forsythe Jan 23 '20 at 00:36
  • @DarrenForsythe I added ` maven-repo https://repo.maven.apache.org/maven2 ` to `setting.xml` and I am on my private network. Still getting `501`. Logs indiacte `http://repo.maven.apache.org/maven2` without `https`. Can you please shed some light there? – Shabar Jan 23 '20 at 05:06
  • @SiKing Yes, it works when I switch to personal network. But still when switch to corporate network. It throws `[ERROR] Failed to execute goal on project api-automation: Could not resolve dependencies for project api-automation:api-automation:jar:1.0-SNAPSHOT: Failed to collect dependencies for [com.github.tomakehurst:wiremock:jar:2.3.1 (compile), junit:ju nit:jar:4.12 (compile)]: Failed to read artifact descriptor for org.ow2.asm:asm:jar:5.0.3: Could not transfer artifact org.ow2:ow2:pom:1.3 from/to central (http://repo.maven.apache.org/maven2): repo.maven.apache.org: Unknown host repo.m` – Shabar Jan 23 '20 at 22:12

0 Answers0