首页 > 解决方案 > 为什么我在IntelliJ中运行项目时maven使用旧版本的Vaadin插件?

问题描述

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

一个非常丑陋的问题发生了,我不明白为什么。当我通过 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>

标签: javamavenintellij-ideavaadin-flowvaadin14

解决方案


尝试以下步骤:

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

推荐阅读