【问题标题】:Maven doesnt add *.gwt.xml file to target floderMaven 不会将 *.gwt.xml 文件添加到目标文件夹
【发布时间】:2017-07-24 20:51:23
【问题描述】:

我正在尝试使用以下属性构建 spring+gwt 项目:

    <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张图片便于理解。怎么回事?

我真的不明白为什么会这样......

【问题讨论】:

  • 有人要问:你为什么要那个?或者,更确切地说,你确定你需要它吗?如果你真的这样做了,不如简单地将文件移动到src/main/resources
  • 我试图将它移动到资源文件夹,但在这种情况下,maven-gwt-plugin 抱怨“模块继承”,结果构建失败。我阅读了 GWT 教程,并有 ant 使用此文件构建目标文件夹。我认为 maven 应该做同样的工作。
  • 您不需要输出文件夹中的 gwt.xml 或 Java 文件。对我来说,看起来你的问题不是问题。如果你的项目不起作用,那应该是别的东西。

标签: maven gwt


【解决方案1】:

您看到的行为是 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>

【讨论】:

    猜你喜欢
    • 2021-08-20
    • 2018-05-25
    • 1970-01-01
    • 2014-05-26
    • 1970-01-01
    • 2013-04-28
    • 1970-01-01
    • 2018-08-01
    • 2013-12-17
    相关资源
    最近更新 更多