代码之家  ›  专栏  ›  技术社区  ›  Tyvain

vaadin10和springboot-如何包装一个罐子?

  •  1
  • Tyvain  · 技术社区  · 6 年前

    问题很简单,但我花了2天时间尝试部署我的应用程序。到目前为止还没有。

    如本文所述: Spring Boot Executable jar structure “您应该将静态资源放在src/main/resources中。”

    所以把css放在这里: src/main/resources/styles.css

    在Vaadin文档中(非常关注如何打包…),我将css导入如下:

    @StyleSheet("styles.css")
    

    资料来源: https://vaadin.com/docs/v11/flow/importing-dependencies/tutorial-include-css.html

    然后我打包我的项目:

     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
    

    2 回复  |  直到 6 年前
        1
  •  2
  •   Tyvain    6 年前

    最后是解决方案

    css必须在这里:

    src/main/resources/META-INF/resources/frontend/styles.css
    

    @StyleSheet("frontend://styles.css")
    
        2
  •  1
  •   the hand of NOD    6 年前

    这也会有帮助,尽管我仍然错过了一个例子:

    Vaadin 10对加载静态资源的方式做了一些改变, 例如应用程序模板、自定义样式和任何其他 JavaScript文件。其要旨是这样的档案应该放进去 src/main/webapp/frontend/生成.war文件时

    连接到Vaadin Dokumentation: Vaadin 10 and static resources