无法在Eclipse IDE中更改Maven版本 [英] Cannot change Maven version in Eclipse IDE

查看:170
本文介绍了无法在Eclipse IDE中更改Maven版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Eclipse中没有mvn包但在终端中成功之后,我意识到Eclipse正在运行 Maven 3.3.3 ,而终端正在运行 3.3.9 。我试图通过所有明显的帐户成功,通过转到 Eclipse - >重新配置eclipse。偏好 - > Maven - >安装并指向我的 3.3.9 文件夹。我重新启动Eclipse并再次尝试但没有可用。此外,尝试构建时,不会确认对 pom.xml 文件的更改。我插入了不适当的斜杠和其他字符,我只能生成此错误:



汇编WAR时出错:需要web.xml属性(或预先存在的WEB- INF / web.xml如果在更新模式下执行)



我按照



这给了我以下输出:

  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版本:1.7 .0_80,供应商:Oracle Corporation
Java home:C:\Program Files \ Java \ _ddk1.7.0_80 \ jre
默认语言环境:en_US,平台编码:UTF-8
操作系统名称:windows 8.1,版本:6.3,arch:amd64,系列:windows


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>

解决方案

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:

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"

这篇关于无法在Eclipse IDE中更改Maven版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆