【问题标题】:Create tomcat - maven project with eclipse in ubuntu在 ubuntu 中使用 eclipse 创建 tomcat - maven 项目
【发布时间】:2014-01-06 19:30:55
【问题描述】:

我正在尝试使用 maven 创建一个 webapp,我按照以下指南操作:http://www.youtube.com/watch?v=YeC7XQho-O0

当我创建项目时,它会说这个警告:

There are no JREs installed in the workspace that are strictly compatible with this environment.    testM6      Build path  JRE System Library Problem

我的 .pom 文件是

<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>ac.web.test</groupId>
  <artifactId>testM6</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>war</packaging>

  <name>testM6</name>
  <url>http://maven.apache.org</url>

  <dependencies>
    <dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>servlet-api</artifactId>
      <version>2.4</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>javax.servlet.jsp</groupId>
      <artifactId>jsp-api</artifactId>
      <version>2.1</version>
      <scope>provided</scope>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>2.0.2</version>
        <configuration>
          <source>1.4</source>
          <target>1.4</target> 
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>

当我尝试切换到这个构建标签时:

<build>
  <plugins>

    <plugin>
      <groupId>org.apache.tomcat.maven</groupId>
      <artifactId>tomcat7-maven-plugin</artifactId>
      <version>2.0</version>
    </plugin>

   </plugins>
  </build>

我收到此警告:

 Description Resource Path Location Type
 Build path specifies execution environment J2SE-1.5. There are no JREs installed in the workspace that are strictly compatible with this environment.
 testM6 Build path JRE System Library Problem

我想念什么?

非常感谢大家

我解决了这个Warning - Build path specifies execution environment J2SE-1.4

但我不明白为什么它不会自动

【问题讨论】:

  • 你安装了Java吗?
  • 只是出于兴趣 - 您是否有理由使用旧的 2.4 servlet api 而不是 3.x?
  • 不,这只是 Eclipse 所做的,我将很快用新的 api 替换,但是感谢您的通知

标签: java eclipse maven jakarta-ee tomcat


【解决方案1】:

我看到您的系统中安装了 java 1.5,并且您正在尝试使用 Tomcat 7。根据this link,运行 Tomcat 7 的最低要求是 java 1.6。

【讨论】:

  • 是的,我解决了这个stackoverflow.com/questions/3138384/…,但我不明白为什么它不会自动
  • 如果你提供了正确的 Maven pom 配置,它就可以了。
  • @Gimby 如何正确设置它以使用 java 1.7?
  • 尝试阅读您已经收到的回复并找出答案?
  • 我已经设置了 Ralf 所说的配置,但它不会自动进行任何更改
【解决方案2】:

Eclipse 正在根据您的 POM 文件创建构建路径。包括 JRE 系统库。在编译器插件的配置中,您指定了源代码与 Java 1.4 兼容,并且您希望它被编译为与 Java 1.4 兼容。 Eclipse 警告您它与您的标记视图中的“构建路径警告”不完全匹配。 Maven 在运行时也会这样做。如果您没有使用 JDK 1.4 为您的 maven 构建配置 Eclipse 运行配置,那么 Eclipse 将选择任何可用的 JDK(默认 JRE)来运行 Maven,并且 Maven 会警告您它可能不会产生您所期望的事实。

如果你在Eclipse中配置了JDK 7,那么你需要设置如下作为编译插件的配置:

<configuration>
    <source>1.7</source>
    <target>1.7</target> 
</configuration>

完成此操作后,警告应该会消失。 Eclipse Marker 和 Maven 在运行时吐出的警告。

【讨论】:

  • 我通过添加代码解决了。用“maven-compiler”添加tomcat插件是否正确?
  • 是否需要tomcat插件取决于你想要实现什么。如果您只想在 Eclipse 中的 tomcat 中部署和运行具有标准 maven 布局的 Web 项目,那么您不需要 Tomcat Maven 插件。 Eclipse m2wtp 插件会解决这个问题。
  • 有你的链接,我在哪里可以知道什么是maven插件?
  • 只用谷歌搜索 tomcat7-maven-plugin,你应该会找到你要找的东西。
猜你喜欢
  • 1970-01-01
  • 2011-02-22
  • 2016-01-07
  • 1970-01-01
  • 2015-07-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-05-21
相关资源
最近更新 更多