2017-07-24 20 views
1

我想建立春+ GWT项目的下一个属性:Maven的犯规加* .gwt.xml文件到目标floder

<groupId>ru.beleychev</groupId> 
<artifactId>notes</artifactId> 
<version>0.0.1-SNAPSHOT</version> 
<packaging>war</packaging> 

<name>notes</name> 
<description>Project for resume</description> 

<parent> 
    <groupId>org.springframework.boot</groupId> 
    <artifactId>spring-boot-starter-parent</artifactId> 
    <version>1.5.4.RELEASE</version> 
    <relativePath/> <!-- lookup parent from repository --> 
</parent> 

<properties> 
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> 
    <java.version>1.8</java.version> 
</properties> 

<dependencies> 
    <dependency> 
     <groupId>org.springframework.boot</groupId> 
     <artifactId>spring-boot-starter-data-jpa</artifactId> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework.boot</groupId> 
     <artifactId>spring-boot-starter-data-rest</artifactId> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework.boot</groupId> 
     <artifactId>spring-boot-starter-security</artifactId> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework.boot</groupId> 
     <artifactId>spring-boot-starter-thymeleaf</artifactId> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework.security</groupId> 
     <artifactId>spring-security-taglibs</artifactId> 
    </dependency> 
    <dependency> 
     <groupId>org.thymeleaf.extras</groupId> 
     <artifactId>thymeleaf-extras-springsecurity4</artifactId> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework.boot</groupId> 
     <artifactId>spring-boot-starter-web</artifactId> 
    </dependency> 

    <dependency> 
     <groupId>mysql</groupId> 
     <artifactId>mysql-connector-java</artifactId> 
     <scope>runtime</scope> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework.boot</groupId> 
     <artifactId>spring-boot-starter-tomcat</artifactId> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework.boot</groupId> 
     <artifactId>spring-boot-starter-test</artifactId> 
     <scope>test</scope> 
    </dependency> 

    <!--GWT--> 
    <dependency> 
     <groupId>com.google.gwt</groupId> 
     <artifactId>gwt-user</artifactId> 
     <version>2.8.1</version> 
    </dependency> 
    <dependency> 
     <groupId>com.google.gwt</groupId> 
     <artifactId>gwt-servlet</artifactId> 
     <version>2.8.1</version> 
    </dependency> 
</dependencies> 

<build> 
    <finalName>${project.artifactId}</finalName> 
    <outputDirectory>target/${project.artifactId}/WEB-INF/classes</outputDirectory> 
    <plugins> 
     <plugin> 
      <groupId>org.codehaus.mojo</groupId> 
      <artifactId>gwt-maven-plugin</artifactId> 
      <version>2.8.1</version> 
      <executions> 
       <execution> 
        <phase>process-resources</phase> 
        <goals> 
         <goal>compile</goal> 
         <goal>test</goal> 
        </goals> 
       </execution> 
      </executions> 
      <configuration> 
       <webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory> 
      </configuration> 
     </plugin> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-compiler-plugin</artifactId> 
      <configuration> 
       <source>${maven.compiler.source}</source> 
       <target>${maven.compiler.target}</target> 
      </configuration> 
     </plugin> 
    </plugins> 
</build> 

的事情是,建成后我不能找到NotesGwtApp.gwt.xml文件:) 有2张图片可以更好地理解。到底是怎么回事?

Output structure Project structure

我真的不明白这是为什么......

+0

有一个问题:您为什么要这么做?或者,相反,你确定你需要它吗?如果你真的这么做,那么简单地把文件移动到'src/main/resources'? –

+0

我试图将其移动到资源文件夹上,但在这种情况下,maven-gwt-plugin抱怨“模块继承”并且结果编译失败。我读了GWT教程,并有** ant **用这个文件构建目标文件夹。我认为maven应该做同样的工作。 –

+0

您不需要输出文件夹中的gwt.xml或Java文件。对我来说,看起来你的问题不是问题。如果你的项目不起作用,它应该是别的。 –

回答

2

你看到的行为是Maven的标准。这是因为默认情况下,Maven仅在src/main/java文件夹中查找.java文件,而某些工具默认情况下可能包含所有文件,因此会造成混淆。

您需要告诉Maven您的src/main/java文件夹中还有非Java资源;您可能需要添加一块配置,例如:

<resources> 
     <resource> 
      <directory>src/main/java</directory> 
      <includes> 
       <include>**/*</include> 
      </includes> 
      <excludes> 
       <exclude>**/*.java</exclude> 
      </excludes> 
     </resource> 
    </resources> 
+0

它已经工作。谢谢! –