Java 如何更改前端文件夹位置并在Vaadin14中进行配置?

Java 如何更改前端文件夹位置并在Vaadin14中进行配置?,java,maven,vaadin,vaadin-flow,vaadin14,Java,Maven,Vaadin,Vaadin Flow,Vaadin14,如何将maven Vaadin 14项目中的默认前端文件夹位置从${project.basedir}/frontend更改为${project.basedir}/src/main/frontend 另外,Vaadin插件在maven build输出目录中输出前端文件夹,而不是我所期望的war分解目录 既然我没有将这个文件夹映射到我的web.xml文件中,它是如何工作的 如何使其将前端文件夹放入war存档,并查看它使用的配置,以使编译后的前端对我的应用程序可见?Vaadin在开发和生产模式中使用前

如何将maven Vaadin 14项目中的默认前端文件夹位置从
${project.basedir}/frontend
更改为
${project.basedir}/src/main/frontend

另外,Vaadin插件在maven build输出目录中输出前端文件夹,而不是我所期望的war分解目录

既然我没有将这个文件夹映射到我的web.xml文件中,它是如何工作的


如何使其将前端文件夹放入war存档,并查看它使用的配置,以使编译后的前端对我的应用程序可见?

Vaadin在开发和生产模式中使用前端文件夹的方式不同。在生产中,它使用
构建前端
目标构建前端。Vaadin Maven插件没有适当的文档,我发现解释每个目标的最佳位置是:。本页说明,
build frontend
负责在生产模式下构建并将前端处理成WEB-INF\classes\META-INF\VAADIN\build

开发模式非常不同,开发说明解释说,如果不使用嵌入式服务器,则应配置IDE以在部署前运行
准备前端
目标:。但是
prepare frontend
只是将空的frontend文件夹创建到目标中,如果文件夹是空的,并且没有任何内容复制到文件夹中,它如何查找前端文件?答:运行应用程序时,Vaadin有一个DevModeInitializer,它将文件
生成的flow imports.js
创建到目标/前端,直接引用项目源文件,以便可以立即反映在这些文件上所做的任何修改,这就是为什么web.xml或上下文侦听器中不需要任何配置的原因

Dev模式对frontend文件夹进行了某种攻击,以使开发更加顺畅,prod模式将frontend中的所有内容编译成一个由Vaadin servlet提供服务的小型文件,因此只有在prod模式下,frontend才会进入war文件。在第一种情况下,必须使用
准备前端
,在第二种情况下,还必须使用
构建前端
。因此,为了修改前端文件夹位置,必须在以下两个目标中更改插件配置:

<plugin>
    <groupId>com.vaadin</groupId>
    <artifactId>vaadin-maven-plugin</artifactId>
    <version>${vaadin.version}</version>
    <executions>
        <execution>
            <goals>
                <goal>prepare-frontend</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <frontendDirectory>${project.basedir}/src/main/frontend</frontendDirectory>
    </configuration>
</plugin>

com.vaadin
vaadin maven插件
${vaadin.version}
准备前端
${project.basedir}/src/main/frontend

生产
真的
com.vaadin
流服务器生产模式
com.vaadin
vaadin maven插件
构建前端
编译
${project.basedir}/src/main/frontend

这样,修改将在开发模式和生产模式下都有效。

我不明白您为什么要更改它。因为这会打乱我的项目组织。因为它应该是简单的,但似乎不是。我也不明白我如何部署我的战争爆发的应用程序,它会在没有任何规范的情况下找到那个文件夹。但是你不需要改变任何东西。Vaadin插件为您做了所有事情,部署工作很好。是的,我没有处理新的应用程序,因此,不,取消部署不会像在绿地项目中那样顺利,将前端留在根目录下会扰乱其组织。我还认为它也会破坏多模块项目,因此我认为最好将其放在src/main上,源代码应该在maven项目中,并保持显式配置以避免将来出现问题。一、 但是,我不明白了解我的动机如何帮助你回答我的问题。无论如何,我已经知道如何正确地更改文件夹位置,我不知道插件在做什么,以及Vaadin如何在开发和生产模式下处理前端文件夹,并且没有插件的文档,所以花了一些时间才弄明白。
<profiles>
    <profile>
        <!-- Production mode is activated using -Pproduction -->
        <id>production</id>
        <properties>
            <vaadin.productionMode>true</vaadin.productionMode>
        </properties>

        <dependencies>
            <dependency>
                <groupId>com.vaadin</groupId>
                <artifactId>flow-server-production-mode</artifactId>
            </dependency>
        </dependencies>

        <build>
            <plugins>
                <plugin>
                    <groupId>com.vaadin</groupId>
                    <artifactId>vaadin-maven-plugin</artifactId>
                    <executions>
                        <execution>
                            <goals>
                                <goal>build-frontend</goal>
                            </goals>
                            <phase>compile</phase>
                        </execution>
                    </executions>
                    <configuration>
                        <frontendDirectory>${project.basedir}/src/main/frontend</frontendDirectory>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    </profile>