You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Vaadin 24构建成功但命令行运行失败:找不到DevModeHandlerManager实现

解决Vaadin 24.3.11 JAR运行时找不到DevModeHandlerManager的问题

核心原因

这个错误是因为生产构建的JAR中混入了开发模式的触发逻辑,而DevModeHandlerManager这类开发模式专属类仅存在于Vaadin的开发依赖中,生产打包时不会被包含,导致运行时找不到实现。

具体解决方案

1. 用生产Profile执行Maven构建

Vaadin默认通过Maven Profile区分开发/生产环境,构建时必须明确指定生产Profile,确保剔除开发依赖并完成前端资源的生产优化:

mvn clean package -Pproduction

2. 修正Vaadin Maven插件配置

确保插件配置明确启用生产模式,避免残留开发相关设置:

<plugin>
    <groupId>com.vaadin</groupId>
    <artifactId>vaadin-maven-plugin</artifactId>
    <version>24.3.11</version>
    <executions>
        <execution>
            <goals>
                <goal>prepare-frontend</goal>
                <goal>build-frontend</goal>
            </goals>
            <phase>compile</phase>
        </execution>
    </executions>
    <configuration>
        <productionMode>true</productionMode> <!-- 关键配置:强制生产模式 -->
        <frontendHotdeploy>false</frontendHotdeploy>
    </configuration>
</plugin>

3. 移除启动命令中的--trace参数

--trace是Vaadin开发模式专属参数,生产环境JAR不支持该参数,直接用标准命令启动:

java -jar filename.jar

如果需要调试日志,改用Spring Boot原生日志参数,例如:

java -jar filename.jar --logging.level.com.vaadin=DEBUG

4. 彻底清理缓存后重新构建

本地Maven缓存可能残留开发依赖,执行以下命令强制更新并重新构建:

mvn clean install -U -Pproduction

-U参数会强制刷新所有依赖,避免使用缓存的旧版本文件。

5. 检查启动类的开发模式注解

确保Spring Boot启动类没有引入@EnableVaadinDevMode这类仅用于开发的注解,生产环境必须移除该类配置。

内容的提问来源于stack exchange,提问作者Luigino

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.23 21:57:02