Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot change Maven version in Eclipse IDE

After failing to mvn package inside of Eclipse but succeeding in the terminal, I realized that Eclipse was running Maven 3.3.3 while terminal was running 3.3.9. I attempted, and by all apparent accounts succeeded, to reconfigure eclipse by going to Eclipse -> Preferences -> Maven -> Installations and pointing to my 3.3.9 folder. I restarted Eclipse and tried again but to no available. Also, changes to the pom.xml file are not acknowledged when attempting to build. I've inserted inappropriate slashes and other characters and am only able to generate this error:

Error assembling WAR: web.xml attribute is required (or pre-existing WEB-INF/web.xml if executing in update mode)

I modified my pom file as per this recommendation but as I said, maven is not recognizing changes to the pom and I cannot get running mvn --version to produce 3.3.9 as it should. I've attached my pom.xml below

<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.javawebtutor</groupId>
<artifactId>LoginWebApp</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>LoginWebApp Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>servlet-api</artifactId>
        <version>2.5</version>
    </dependency>
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>5.1.30</version>
    </dependency>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.10</version>
    </dependency>
</dependencies>
<build>
    <finalName>LoginWebApp</finalName>
    <plugins>
    <plugin>            
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-war-plugin</artifactId>
      <configuration>
        <webXml>src\main\webapp\WEB-INF\web.xml</webXml>        
      </configuration>
    </plugin>
    </plugins>
</build>

like image 950
Austin Wehn Avatar asked Feb 21 '16 00:02

Austin Wehn


2 Answers

  • Call cmd, type systempropertiesadvanced Check environment variables: %MAVEN_HOME%, %PATH%.
  • Check these steps: enter image description here



Look at the below screenshot (this is relate to your problem):

EMBEDDED: 3.3.3
outsite Eclipse: 3.3.9

enter image description here

enter image description here

enter image description here

enter image description here

(source: http://codingvn.com/2016/02/08/cau-hinh-de-eclipse-su-dung-ban-cai-dat-maven-ben-ngoai-ide/ this is my website)

like image 169
Do Nhu Vy Avatar answered Oct 06 '22 03:10

Do Nhu Vy


Try setting up a runtime configuration, or see if you're using one already.

In eclipse, right click on the project->run as->run configurations. Look for the m2 Maven Build section on the left. If there is one under your project's name, then edit it, otherwise, create one. On the bottom of the dialog there is a drop down that allows you to select which maven configuration you want to run:

enter image description here

This gives me the following output:

Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11 10T11:41:47-05:00)
Maven home: C:\Program Files\Java\apache-maven-3.3.9
Java version: 1.7.0_80, vendor: Oracle Corporation
Java home: C:\Program Files\Java\jdk1.7.0_80\jre
Default locale: en_US, platform encoding: UTF-8
OS name: "windows 8.1", version: "6.3", arch: "amd64", family: "windows"
like image 24
K.Nicholas Avatar answered Oct 06 '22 01:10

K.Nicholas