web-applications - 输出 jar 中没有 webapp 文件夹

标签 web-applications jar spring-boot vaadin

我正在使用 Vaadin 和 Spring Boot 构建一个简单的 Web 应用程序。当我使用 mvn package 构建它时并通过 java -jar <path_to_jar> 运行看来有效。

但是有一件事让我困惑。当我进入项目文件夹并运行 java -jar target/app.jar它似乎工作正常。但是如果我出去并运行它 java -jar <full_path_to_jar>它有效,但主题消失了。我检查了 Chrome Inspector 的输出,它返回 404对于 /VAADIN/themes/mytheme/styles.css?v=7.5.5

如何将主题打包到 jar 中?

最佳答案

从您的问题标题来看,您似乎使用过src/main/webapp。如explained in the documentation ,在构建 jar 时不应该这样做:

Do not use the src/main/webapp directory if your application will be packaged as a jar. Although this directory is a common standard, it will only work with war packaging and it will be silently ignored by most build tools if you generate a jar.

相反,您应该将静态内容放在 src/main/resources/static 下。

关于web-applications - 输出 jar 中没有 webapp 文件夹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33052825/

相关文章:

Java Web 应用程序,可以将任意文件的内容流式传输到浏览器(live tail)

java - 用于管理多个 Web 应用程序配置的工具

java - 使用 jar 的简单类路径问题

Maven:在 war 构建的资源文件夹中包含文件夹

java - 编译并构建 asmack 的 jar

java - Spring-Cloud-Stream-Kafka-Binder 功能风格忽略自定义 De/Serializer 和/或 useNativeEncoding?

iphone - 检测滑动 Action 以转到 ipad Web 应用程序上的另一个网页

mysql - 什么时候项目对 mysql 来说太大了

java - 如何使用spring boot设置kafka消费者并发

java - 当我指定 spring.config.location 时,Spring Boot 2.x 不扫描 application.properties