2

运行 Web 应用程序时,Tomcat 出现问题。这是我的相关部分pom.xml

<build>
<plugins>
    <plugin>
      <groupId>org.apache.tomcat.maven</groupId>
      <artifactId>tomcat7-maven-plugin</artifactId>
      <version>7</version>
    </plugin>
</plugins>
</build>

当我使用m2eclipse ( tomcat:run) 运行时,出现此错误:

[INFO] Scanning for projects...
[WARNING] The POM for org.apache.tomcat.maven:tomcat7-maven-plugin:jar:7 is missing, no dependency information available
[WARNING] Failed to retrieve plugin descriptor for org.apache.tomcat.maven:tomcat7-maven-plugin:7: Plugin org.apache.tomcat.maven:tomcat7-maven-plugin:7 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.tomcat.maven:tomcat7-maven-plugin:jar:7
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building ourtest 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[WARNING] The POM for org.apache.tomcat.maven:tomcat7-maven-plugin:jar:7 is missing, no dependency information available
[WARNING] Failed to retrieve plugin descriptor for org.apache.tomcat.maven:tomcat7-maven-plugin:7: Plugin org.apache.tomcat.maven:tomcat7-maven-plugin:7 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.tomcat.maven:tomcat7-maven-plugin:jar:7
[INFO] 
[INFO] >>> tomcat-maven-plugin:1.1:run (default-cli) @ ourtest >>>
[INFO] 
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ ourtest ---
[debug] execute contextualize
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Users\user\Documents\EclipseProjects\ourtest\src\main\resources
[INFO] 
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ ourtest ---
[INFO] Compiling 7 source files to C:\Users\user\Documents\EclipseProjects\ourtest\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] Unable to locate the Javac Compiler in:
  C:\Program Files\Java\jre7\..\lib\tools.jar
Please ensure you are using JDK 1.4 or above and
not a JRE (the com.sun.tools.javac.Main class is required).
In most cases you can change the location of your Java
installation by setting the JAVA_HOME environment variable.
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.317s
[INFO] Finished at: Tue Mar 05 15:50:20 GMT+01:00 2013
[INFO] Final Memory: 6M/15M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project ourtest: Compilation failure
[ERROR] Unable to locate the Javac Compiler in:
[ERROR] C:\Program Files\Java\jre7\..\lib\tools.jar
[ERROR] Please ensure you are using JDK 1.4 or above and
[ERROR] not a JRE (the com.sun.tools.javac.Main class is required).
[ERROR] In most cases you can change the location of your Java
[ERROR] installation by setting the JAVA_HOME environment variable.
[ERROR] -> [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/MojoFailureException

我测试了很多配置,pom.xml但没有结果。

4

4 回答 4

4

尝试改变两件事:

1) 更新 tomcat7-maven-plugin 版本为 2.1

2)使用“mvn tomcat7:运行”

指定的版本不存在,您使用的命令将运行旧的 codehaus 插件。

于 2013-08-01T22:29:11.403 回答
1

请参阅与此问题相关的 M2Eclipse常见问题解答。

于 2013-03-05T16:49:49.797 回答
0

要检查您的 JAVA_HOME 环境变量,您需要在命令行 (WIN) 中键入 java --version。这可以告诉你如果你的系统。使用 JDK 或 JRE。您也可以转到 MyComputer -> Properties -> Advanced -> environment variables 并在列表中查看 JAVA_HOME 是什么(我不使用 Win 的英文版,因此名称可能有点不同)。要在 Eclipse 中更改 JRE(我正在使用 Juno),请转到 Project Properies -> Java Build Path -> Libraries Tab -> Add a JDK lib if not present。

于 2013-04-11T11:36:03.630 回答
0

Maven 可能在 JRE 而不是 JDK 中寻找编译器 确保将类路径设置为 JDK

找不到 Javac 编译器

于 2013-05-25T21:14:29.013 回答