Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could not understand about Maven pom file using Eclipse

Tags:

eclipse

maven

I am very new to Maven and i am creating my first maven project of maven-archetype-quickstart enter image description here

enter image description here

Then it generates the error message ::

enter image description here

But in my project explorer :

enter image description here

I am unable to understand that why it is creating a proper maven project every time it shows a red warning mark into my project and as well as in my pom.xml file.

> 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.akash</groupId>
  <artifactId>feind</artifactId>
  <version>0.0.1-SNAPSHOT</version>

  <name>feind</name>
  <!-- FIXME change it to the project's website -->
  <url>http://www.example.com</url>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>1.7</maven.compiler.source>
    <maven.compiler.target>1.7</maven.compiler.target>
  </properties>

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.11</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
      <plugins>
        <!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
        <plugin>
          <artifactId>maven-clean-plugin</artifactId>
          <version>3.1.0</version>
        </plugin>
        <!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
        <plugin>
          <artifactId>maven-resources-plugin</artifactId>
          <version>3.0.2</version>
        </plugin>
        <plugin>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>3.8.0</version>
        </plugin>
        <plugin>
          <artifactId>maven-surefire-plugin</artifactId>
          <version>2.22.1</version>
        </plugin>
        <plugin>
          <artifactId>maven-jar-plugin</artifactId>
          <version>3.0.2</version>
        </plugin>
        <plugin>
          <artifactId>maven-install-plugin</artifactId>
          <version>2.5.2</version>
        </plugin>
        <plugin>
          <artifactId>maven-deploy-plugin</artifactId>
          <version>2.8.2</version>
        </plugin>
        <!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
        <plugin>
          <artifactId>maven-site-plugin</artifactId>
          <version>3.7.1</version>
        </plugin>
        <plugin>
          <artifactId>maven-project-info-reports-plugin</artifactId>
          <version>3.0.0</version>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>
</project>

settings.xml

<?xml version="1.0" encoding="UTF-8"?>
<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">

  <!--  Change username in below line  -->        
  <localRepository>/Users/COACH/.m2/repository</localRepository>

  <interactiveMode>true</interactiveMode>

  <offline>false</offline>

  <pluginGroups>
    <!-- pluginGroup
     | Specifies a further group identifier to use for plugin lookup.
    <pluginGroup>com.your.plugins</pluginGroup>
    -->
  </pluginGroups>

  <proxies>
    <!--
    <proxy>
      <id>optional</id>
      <active>true</active>
      <protocol>http</protocol>
      <username>proxyuser</username>
      <password>proxypass</password>
      <host>proxy.host.net</host>
      <port>80</port>
      <nonProxyHosts>local.net|some.host.com</nonProxyHosts>
    </proxy>
    -->
  </proxies>

  <servers>
    <!--
    <server>
      <id>deploymentRepo</id>
      <username>crunchify</username>
      <password>crunchify</password>
    </server>
  -->
  </servers>

  <mirrors>
    <!--
    <mirror>
      <id>mirrorId</id>
      <mirrorOf>repositoryId</mirrorOf>
      <name>mirror description</name>
      <url>http://my.repository.com/repo/path</url> 
    </mirror>
    -->
  </mirrors>

  <profiles>
  </profiles>

</settings>

I am fail to understand that why this happening every time to me and my .m2\repository folder is also empty . Please suggest me some steps to fix it and properly run a maven project.

like image 623
Akash Avatar asked Oct 28 '19 10:10

Akash


People also ask

How do you know if a Pom is effective in Eclipse?

The Overview tab is useful to manage project coordinates, parent or modules of the project and properties. With the Dependencies tab, we can manage project dependencies. While the Dependency Hierarchy tab shows how project dependencies are organized, the Effective POM tab displays the effective POM of the project.

Is there a pom XML file in Maven?

Of course there is no pom.xml file. I am no longer using Maven. When I open the project Properties, the only item listed under Project Natures is Java.

How to clean Maven project in Eclipse IDE?

Task-1: Perform “Project Clean” in Eclipse IDE Step-1. Create new maven based project or open existing maven project. In my case, I’m opening my existing Simplest Spring MVC Hello World Project in Eclipse. Step-2. Click on Project Menu item in Eclipse; Choose Clean... option from list; Step-3. Select a project which you want to clean or ...

How do I update my Maven project in Eclipse?

How do I update my Maven project to work in Eclipse? How to fix error “Updating Maven Project”? Create new maven based project or open existing maven project. In my case, I’m opening my existing Simplest Spring MVC Hello World Project in Eclipse. Click on Update Project... Click on Maven build...

What is eclipse Maven tooling?

This tooling manages the project dependencies and updates the classpath of the project dependencies in the Eclipse IDE. It ensures that the Maven experience in Eclipse is as smooth as possible. The tooling also provides different kind of wizards import andto create new Maven based projects.


2 Answers

Since i am not behind any proxy so i don't need to worry about the settings.xml file i just deleted .m2 folder and just simply try to create a maven project again and maven itself downloads the required dependencies automatically.

Hence problem is resolved.

like image 51
Akash Avatar answered Sep 28 '22 16:09

Akash


As reputable sources go:

  • apache/maven PR 38 illustrates you should not define any M2_HOME (not with recent maven versions)
  • apache-maven/src/bin/mvn shows that, if MAVEN_HOME is not defined, it defaults to where maven is installed.

By deleting your ~/.m2 folder, you have forced Eclipse (through m2e, included in any Eclipse 4.5 or newer), to revert back to a default m2 folder.
It also uses, per FAQ, the default <maven home>/conf/settings.xml

like image 44
VonC Avatar answered Sep 28 '22 18:09

VonC