【问题标题】:STS/Eclipse "Java EE" perspective does not recognise maven directory structureSTS/Eclipse“Java EE”透视图不识别maven目录结构
【发布时间】:2011-09-27 23:48:27
【问题描述】:

我是 maven 新手,我正在尝试让 eclipse 在使用动态 Web 项目透视图时识别 maven 目录结构。

所以我从这里的问题开始:A Java web project created with Maven is not recognized as such by Eclipse,我已经走到了这一步:

  • 我将 pom.xml 中的 eclipse-plugin 编辑为:

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-eclipse-plugin</artifactId>
          <version>2.6</version>
          <configuration>
            <wtpmanifest>true</wtpmanifest>
            <wtpapplicationxml>true</wtpapplicationxml>
            <wtpversion>2.0</wtpversion>             
            <downloadSources>true</downloadSources>
            <additionalBuildcommands>
              <buildcommand>com.atlassw.tools.eclipse.checkstyle.CheckstyleBuilder</buildcommand>
            </additionalBuildcommands>
            <additionalConfig>
              <file>
                <name>.checkstyle</name>
                <url>http://rs.gbif.org/conventions/java-style-config.xml</url>
              </file>
            </additionalConfig>
          </configuration>
        </plugin>
    
  • 然后我使用了命令

    mvn eclipse:eclipse
    

它给出了以下输出:

     [INFO] Scanning for projects...
     [INFO]
     [INFO] ------------------------------------------------------------------------
     [INFO] Building IPT 2.0.3-SNAPSHOT
     [INFO] ------------------------------------------------------------------------
     [INFO]
     [INFO] >>> maven-eclipse-plugin:2.6:eclipse (default-cli) @ ipt >>>
     [INFO]
     [INFO] --- buildnumber-maven-plugin:1.0-beta-4:create (default) @ ipt ---
     [INFO] Checking for local modifications: skipped.
     [INFO] Updating project files from SCM: skipped.
     [INFO] Executing: cmd.exe /X /C "svn --non-interactive info"
     [INFO] Working directory: C:\IOR_SVN\gbif-providertoolkit-read-only\gbif-ipt
     [INFO] Storing buildNumber: 3391 at timestamp: 1309767247372
     [INFO] Executing: cmd.exe /X /C "svn --non-interactive info"
     [INFO] Working directory: C:\IOR_SVN\gbif-providertoolkit-read-only\gbif-ipt
     [INFO] Storing buildScmBranch: trunk
     [INFO]
     [INFO] <<< maven-eclipse-plugin:2.6:eclipse (default-cli) @ ipt <<<
     [INFO]
     [INFO] --- maven-eclipse-plugin:2.6:eclipse (default-cli) @ ipt ---
     [INFO] Adding support for WTP version 2.0.
     [INFO] Using Eclipse Workspace: null
     [INFO] Adding default classpath container: org.eclipse.jdt.launching.JRE_CONTAIN
     ER
     [WARNING] Invalid POM for org.apache.struts:struts2-core:jar:2.0.5, transitive d
     ependencies (if any) will not be available, enable debug logging for more detail
     s
     [INFO] @@@ TRUE - Manifests are equal
     [INFO] Not writing Manifest file as it is unchanged: C:\IOR_SVN\gbif-providertoo
     lkit-read-only\gbif-ipt\src\main\webapp\META-INF\MANIFEST.MF
     [INFO] Wrote settings to C:\IOR_SVN\gbif-providertoolkit-read-only\gbif-ipt\.set
     tings\org.eclipse.jdt.core.prefs
     [INFO] Wrote Eclipse project for "ipt" to C:\IOR_SVN\gbif-providertoolkit-read-o
     nly\gbif-ipt.

因此,执行此方法后,我在 Eclipse 的“Java 透视图”中识别了我的 Java 文件夹,但是当我转到“Java EE”透视图时,那里什么也没有识别出来。因此无法识别源以及 webapps 文件夹。

在版本方面,我使用的是SpringSource IDE 2.3.1版本,我使用的是maven 3版本(这个版本没有预捆绑maven所以我下载了最新的maven)

【问题讨论】:

  • 你在使用m2eclipse插件吗?

标签: eclipse maven


【解决方案1】:

我在运行 eclipse:eclipse 命令时看到了这种情况,eclipse 上的一些 eclipse 项目方面属性正在改变,要验证这一点,请在 eclipse 中执行此操作

选择项目 ==> 属性 ==> 项目构面 ==> 动态 Web 模块(构面属性)

我认为属性复选框未选中(因此 eclipse 无法识别您的 Web 项目)

【讨论】:

  • 检查了动态 Web 模块方面。虽然如果我更改我的工作区然后导入同一个项目,那么“Java EE 透视图”会正确显示。