【问题标题】:Why maven use the old version of the Vaadin plug-in when I run the project in IntelliJ?为什么我在IntelliJ中运行项目时maven使用旧版本的Vaadin插件?
【发布时间】:2020-07-03 05:50:44
【问题描述】:

我在我的pom.xmlpnpm 中使用vaadin-maven-plugin 14.2.2 并启用Wildfly 20IntelliJ latest 版本。

一个非常丑陋的问题发生了,我不明白为什么。 当我通过 IntelliJ 运行配置运行我的项目时,会发生一些奇怪的事情。 IntelliJ 使用旧版本的 vaadin-plugin,即 vaadin-maven-plugin 14.2.0,我的 pom.xml 中没有它。

我已经尝试 mvn help:effective-pom 来查看 pom 中是否存在此依赖项的多个版本,并使用 mvn dependency:tree 检查了所有传递依赖项

有人知道为什么会发生这种情况,我应该怎么做才能防止它发生?

<properties>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
    <vaadin.version>14.2.2</vaadin.version>
</properties>

<build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-help-plugin</artifactId>
                <version>3.2.0</version>
                <executions>
                    <execution>
                        <id>show-profiles</id>
                        <phase>compile</phase>
                        <goals>
                            <goal>active-profiles</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
            </plugin>
            <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <version>3.2.3</version>
            </plugin>

            <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>
                    <pnpmEnable>true</pnpmEnable>
                </configuration>
            </plugin>
        </plugins>


    </build>
    <profiles>
        <profile>
            <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>
                        <version>${vaadin.version}</version>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>build-frontend</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <pnpmEnable>true</pnpmEnable>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

如果我使用 wildfly 插件并执行 wildfly:run 我会收到以下错误

    ERROR in ../target/frontend/generated-flow-imports-fallback.js
    Module not found: Error: Can't resolve '@vaadin/flow-frontend/?babel-target=es5' in 'C:\workspace\user-web\target\frontend'
     @ ../target/frontend/generated-flow-imports-fallback.js 45:0-32
     @ ../target/frontend/generated-flow-imports.js?babel-target=es5
    ERROR in ../target/frontend/generated-flow-imports-fallback.js
    Module not found: Error: Can't resolve '@vaadin/flow-frontend/?babel-target=es6' in 'C:\workspace\user-web\target\frontend'
     @ ../target/frontend/generated-flow-imports-fallback.js 45:0-32
     @ ../target/frontend/generated-flow-imports.js?babel-target=es6
Failed to execute goal com.vaadin:vaadin-maven-plugin:14.2.2:build-frontend 

    (default) on project user-web: Webpack process exited with non-zero exit code.
    Stderr: ''

            <plugin>
                <groupId>org.wildfly.plugins</groupId>
                <artifactId>wildfly-maven-plugin</artifactId>
                <version>2.1.0.Beta1</version>
                <configuration>
                    <server-args>
                        <server-arg>-Duser.properties.file=C:\appserver.properties</server-arg>
                    </server-args>
                </configuration>
            </plugin>

【问题讨论】:

  • 不能用给定的 pom 复制。你怎么知道使用了错误的插件版本?您使用什么运行配置? maven插件版本可以在插件旁边的Maven工具窗口中看到:monosnap.com/file/zjVl1rsF1sdleZOGxOyUinJnMqFRAC你在那儿看到什么?
  • 我在 maven 工具版本 14.2.2 中看到,当我运行它时,在控制台的输出中我看到旧版本 14.2.0。我确实尝试过使用 wildfly 插件,但出现错误:Failed to execute goal com.vaadin:vaadin-maven-plugin:14.2.2:build-frontend (default) on project user-web: Webpack process exited with non-zero exit code. Stderr: ''

标签: java maven intellij-idea vaadin-flow vaadin14


【解决方案1】:

尝试以下步骤:

  • mvn clean install -U
  • 在 IntelliJ 中打开项目视图
  • 右键单击 pom.xml 文件并
  • 选择 Maven - Reimport 如果这对您有用,IntelliJ 将添加 项目的依赖项
  • 检查您需要的依赖项是否已添加到文件 - 项目中 结构 - 项目设置 - 库和文件 - 项目结构 - 模块 - 依赖项。

【讨论】:

  • 当我运行mvn clean install -U 时出现以下错误。 ../target/frontend/generated-flow-imports-fallback.js 中的错误找不到模块:错误:无法解析 'C:\mediasoft\ 中的 '@vaadin/flow-frontend/?babel-target=es5' user-web\target\frontend' @ ../target/frontend/generated-flow-imports-fallback.js @ ../target/frontend/generated-flow-imports.js?babel-target=es5 错误在.. /target/frontend/generated-flow-imports-fallback.js Module not found: Error: Can't resolve '@vaadin/flow-frontend/?babel-target=es6' in 'C:\mediasoft\user-web\目标\前端'
  • 和这个错误:无法在项目用户网络上执行目标 com.vaadin:vaadin-maven-plugin:14.2.2:build-frontend(默认):Webpack 进程以非零退出退出代码。标准错误:''
猜你喜欢
  • 2021-11-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-10-12
  • 1970-01-01
  • 1970-01-01
  • 2017-07-21
  • 2020-09-07
相关资源
最近更新 更多