2017-08-30 15 views
2

我是GWT和Maven的初學者。我在Eclipse中創建了一個新的GWT應用程序項目。然後,我通過右鍵單擊項目名稱=>將該項目轉換爲Maven項目。配置 =>轉換到Maven項目,我看到爲該項目生成了一個pom文件。接下來,我像Maven build一樣運行項目,但由於沒有指定目標,因此未編譯它。其實,我不明白我在目標板塊下究竟寫了什麼,因此,我寫下了,然後我又構建了maven併成功編譯。在插件org.codehaus.mojo中找不到目標'devmode'

在那之後,我試圖在命令提示符使用下Run the GWT Project提到建立一個新的項目區第2步SuperDevMode運行此Maven項目。但是,在命令提示符下執行這些步驟時,出現無法找到devmode的錯誤。這是我的命令提示符日誌:

C:\Users\TEST>cd eclipse-workspace/MyWebApp 

C:\Users\TEST\eclipse-workspace\MyWebApp>mvn war:exploded 
[INFO] Scanning for projects... 
[INFO] 
[INFO] ------------------------------------------------------------------------ 
[INFO] Building MavenApp 0.0.1-SNAPSHOT 
[INFO] ------------------------------------------------------------------------ 
[INFO] 
[INFO] --- maven-war-plugin:3.1.0:exploded (default-cli) @ abcdef --- 
[INFO] Exploding webapp 
[INFO] Assembling webapp [abcdef] in [C:\Users\TEST\eclipse-workspace\MyWebApp\target\abcdef-0.0.1-SNAPSHOT] 
[INFO] Processing war project 
[INFO] Webapp assembled in [63 msecs] 
[INFO] ------------------------------------------------------------------------ 
[INFO] BUILD SUCCESS 
[INFO] ------------------------------------------------------------------------ 
[INFO] Total time: 0.920 s 
[INFO] Finished at: 2017-08-30T11:24:53+05:30 
[INFO] Final Memory: 12M/107M 
[INFO] ------------------------------------------------------------------------ 

C:\Users\TEST\eclipse-workspace\MyWebApp>mvn gwt:devmode 
[INFO] Scanning for projects... 
[INFO] ------------------------------------------------------------------------ 
[INFO] BUILD FAILURE 
[INFO] ------------------------------------------------------------------------ 
[INFO] Total time: 0.301 s 
[INFO] Finished at: 2017-08-30T11:25:02+05:30 
[INFO] Final Memory: 8M/107M 
[INFO] ------------------------------------------------------------------------ 
[ERROR] Could not find goal 'devmode' in plugin org.codehaus.mojo:gwt-maven-plugin:2.8.1 among available goals clean, compile, compile-report, css, debug, eclipse, eclipseTest, generateAsync, help, i18n, mergewebxml, resources, run, run-codeserver, source-jar, test -> [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/MojoNotFoundException 

這裏是我的pom.xml文件:

<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>MyWebApp</groupId> 
    <artifactId>abcdef</artifactId> 
    <version>0.0.1-SNAPSHOT</version> 
    <build> 
    <sourceDirectory>src</sourceDirectory> 
    <testSourceDirectory>test</testSourceDirectory> 
    <resources> 
     <resource> 
     <directory>src</directory> 
     <excludes> 
      <exclude>**/*.java</exclude> 
     </excludes> 
     </resource> 
    </resources> 
    <plugins> 
     <plugin> 
     <artifactId>maven-compiler-plugin</artifactId> 
     <version>3.6.1</version> 
     <configuration> 
      <source>1.8</source> 
      <target>1.8</target> 
     </configuration> 
     </plugin> 
    </plugins> 
    </build> 
    <name>MavenApp</name> 
    <description>It is a maven app</description> 
</project> 

我搜索了很多解決這個錯誤,但發現這個問題無解。請幫我解決這個問題,因爲我很困惑如何解決這個問題。

編輯:後進一步研究,我用mvn gwt:run作爲替代命令mvn gwt:devmode,但還是我上了命令提示符另一個錯誤下面給出:

[ERROR] Failed to execute goal org.codehaus.mojo:gwt-maven-plugin:2.8.1:run (default-cli) on project MyWebApp: The parameters 'runTarget' for goal org.codehaus.mojo:gwt-maven-plugin:2.8.1:run are missing or invalid 

回答

0

嗯,我能夠通過從pom.xml文件(它是在webAppCreator使用maven創建的項目中生成的)複製一些依賴項,插件和配置來解決此問題到我的pom.xml文件在Eclipse中創建的項目。所以,這是最後創造我的pom.xml文件:

<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>MyPersonalProject</groupId> 
    <artifactId>MyPersonalProject</artifactId> 
    <version>0.0.1-SNAPSHOT</version> 
    <properties> 

    <!-- Setting maven.compiler.source to something different to 1.8 
     needs that you configure the sourceLevel in gwt-maven-plugin since 
     GWT compiler 2.8 requires 1.8 (see gwt-maven-plugin block below) --> 
    <maven.compiler.source>1.8</maven.compiler.source> 
    <maven.compiler.target>1.8</maven.compiler.target> 

    <!-- Don't let your Mac use a crazy non-standard encoding --> 
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> 
    </properties> 
    <dependencyManagement> 
    <dependencies> 
     <!-- ensure all GWT deps use the same version (unless overridden) --> 
     <dependency> 
     <groupId>com.google.gwt</groupId> 
     <artifactId>gwt</artifactId> 
     <version>2.8.1</version> 
     <type>pom</type> 
     <scope>import</scope> 
     </dependency> 
    </dependencies> 
    </dependencyManagement> 

    <dependencies> 
    <dependency> 
     <groupId>com.google.gwt</groupId> 
     <artifactId>gwt-servlet</artifactId> 
     <scope>runtime</scope> 
    </dependency> 
    <dependency> 
     <groupId>com.google.gwt</groupId> 
     <artifactId>gwt-user</artifactId> 
     <scope>provided</scope> 
    </dependency> 
    <dependency> 
     <groupId>com.google.gwt</groupId> 
     <artifactId>gwt-dev</artifactId> 
     <scope>provided</scope> 
    </dependency> 
    <dependency> 
     <groupId>junit</groupId> 
     <artifactId>junit</artifactId> 
     <version>4.11</version> 
     <scope>test</scope> 
    </dependency> 
    </dependencies> 
    <build> 
    <outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF/classes</outputDirectory> 
    <sourceDirectory>src</sourceDirectory> 
    <testSourceDirectory>test</testSourceDirectory> 
    <resources> 
     <resource> 
     <directory>src</directory> 
     <excludes> 
      <exclude>**/*.java</exclude> 
     </excludes> 
     </resource> 
    </resources> 
    <plugins> 
    <plugin> 
     <groupId>net.ltgt.gwt.maven</groupId> 
     <artifactId>gwt-maven-plugin</artifactId> 
     <version>1.0-rc-6</version> 
     <executions> 
      <execution> 
      <goals> 
       <goal>import-sources</goal> 
       <goal>compile</goal> 
       <goal>import-test-sources</goal> 
       <goal>test</goal> 
      </goals> 
      </execution> 
     </executions> 
     <configuration> 
      <moduleName>mypackage.MyPersonalproject</moduleName> 
      <failOnError>true</failOnError> 
      <!-- GWT compiler 2.8 requires 1.8, hence define sourceLevel here if you use 
       a different source language for java compilation --> 
      <sourceLevel>1.8</sourceLevel> 
      <!-- Compiler configuration --> 
      <compilerArgs> 
      <!-- Ask GWT to create the Story of Your Compile (SOYC) (gwt:compile) --> 
      <arg>-compileReport</arg> 
      <arg>-XcompilerMetrics</arg> 
      </compilerArgs> 
      <!-- DevMode configuration --> 
      <warDir>${project.build.directory}/${project.build.finalName}</warDir> 
      <classpathScope>compile+runtime</classpathScope> 
      <!-- URL(s) that should be opened by DevMode (gwt:devmode). --> 
      <startupUrls> 
      <startupUrl>MyPersonalProject.html</startupUrl> 
      </startupUrls> 
     </configuration> 
     </plugin> 
     <plugin> 
     <artifactId>maven-compiler-plugin</artifactId> 
     <version>3.6.1</version> 
     <configuration> 
      <source>1.8</source> 
      <target>1.8</target> 
     </configuration> 
     </plugin> 
    </plugins> 
    </build> 
</project> 

當我運行使用maven在命令提示符這個應用程序,它運行成功,除了顯示在命令提示符日誌2個或3警告。另外,我注意到版本中生成的SNAPSHOT對於Eclipse創建的pom.xml與命令提示符下maven項目創建的pom.xml不同。

1

沒有任何更多的信息比gwt:devmode, Maven會根據其默認設置嘗試找到合適的插件。它發生gwt-maven-plugin作爲groupId與org.codehaus.mojo一起存在,符合Maven內置插件分辨率。

但是,這不是你正在尋找的插件。

你可能嘗試使用this one,所以只需添加到您的的pom.xml,在<plugins>部分:

<plugin> 
    <groupId>net.ltgt.gwt.maven</groupId> 
    <artifactId>gwt-maven-plugin</artifactId> 
    <version>1.0-rc-8</version> 
    <extensions>true</extensions> 
    <configuration> 
    <moduleName>com.example.app.App</moduleName> 
    </configuration> 
</plugin> 

適應的MODULENAME如果需要的話。

+0

我遵循這種方法,但它沒有奏效。 :( – DG4

+0

我猜你在這種情況下有不同的錯誤? – Tome

+0

是的,我在這種情況下遇到了不同的錯誤。 – DG4

相關問題