Maven Vaadin 10和springboot-如何包装一个罐子?
问题很简单,但我花了2天时间尝试部署我的应用程序。到目前为止还没有 我的样式只有一个css文件,当我执行jar时,找不到css(404),或者jar不会打包 如下文所述: “如果应用程序将打包为jar,请不要使用src/main/webapp文件夹” 和 “您应该将静态资源放在src/main/resources中。” 所以把css放在这里: src/main/resources/styles.css 在Vaadin文档中(关于如何打包…),我导入css如下:Maven Vaadin 10和springboot-如何包装一个罐子?,maven,spring-boot,vaadin10,Maven,Spring Boot,Vaadin10,问题很简单,但我花了2天时间尝试部署我的应用程序。到目前为止还没有 我的样式只有一个css文件,当我执行jar时,找不到css(404),或者jar不会打包 如下文所述: “如果应用程序将打包为jar,请不要使用src/main/webapp文件夹” 和 “您应该将静态资源放在src/main/resources中。” 所以把css放在这里: src/main/resources/styles.css 在Vaadin文档中(关于如何打包…),我导入css如下: @StyleSheet("styl
@StyleSheet("styles.css")
资料来源:
然后我打包我的项目:
mvn clean package -Pproduction
我得到这个错误:
[ERROR] Failed to execute goal com.vaadin:vaadin-maven-plugin:11.0.0:package-for-production (default) on project importparcoursup: Execution default of goal com.vaadin:vaadin-maven-plugin:11.0.0:package-for-production failed: An import that ends with 'styles.css' cannot be resolved: the corresponding file 'C:\Workspace\lasteclipeandjava10\parcoursup\target\frontend\styles.css' was not found.
[ERROR] Double check the corresponding import and verify the following:
[ERROR] * the import string is correct
[ERROR] * the file imported is either present in 'frontend://' directory of the project or in one of the project WebJar dependencies or in one of the regular jar dependencies
[ERROR] * if the file is present in one of the regular jar dependencies, it should be located in `META-INF/resources/frontend` directory in the jar
有人能提供一个简单的例子,将“springboot+Vaadin10”应用打包成一个包含静态资源的jar吗
我尝试了很多配置(将css放在META-INF中,在maven构建过程中包括webapp资源…),但2天后,我仍然无法在服务器上部署我的应用 最后是解决方案
css必须在这里:
src/main/resources/META-INF/resources/frontend/styles.css
然后宣布为:
@StyleSheet("frontend://styles.css")
即使我仍然错过了一个例子,这也会很有帮助: Vaadin 10对加载静态资源的方式进行了一些更改, 例如应用程序模板、自定义样式和任何其他 JavaScript文件。它的要点是,这些文件应该放在 src/main/webapp/frontend/在构建.war文件时 src/main/resources/META-INF/resources/frontend/在构建.jar时 文件
链接至Vaadin Dokumentation:供参考,如果您有.html文件,它们也需要位于此文件夹中。