我正在使用 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/