【问题标题】:VAADIN cannot find themes when in productionModeVAADIN 在生产模式下找不到主题
【发布时间】:2013-05-09 19:45:36
【问题描述】:

我在 src/main/webapp/VAADIN/themes/mytheme/ 中有我的 VAADIN 应用程序的自定义主题,其中包含文件 mytheme.scss 和 styles.scss。 当 web.xml 中的 vaadin productionMode 部署参数设置为 false 时,一切正常。当我将参数设置为 true 时,突然 Vaadin 找不到我的主题的资源并不断抱怨:

Requested resource [/VAADIN/themes/mytheme/styles.css] not found from filesystem or through class loader. Add widgetset and/or theme JAR to your classpath or add files to WebContent/VAADIN folder

我没有 /WebContent 目录,而是 /webapp,因为它是一个 maven web-app 项目。 我尝试将 VAADIN 文件夹放到:
src/main/资源
src/main/webapp
src/main/webapp/WEB-INF

但在生产模式下没有任何效果。有什么建议吗? 提前感谢您的帮助。

【问题讨论】:

    标签: java resources themes vaadin vaadin7


    【解决方案1】:

    您需要在 pom.xml 中添加以下目标,这会将 .scss 文件编译为 .css 文件:

    <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <version>1.2.1</version>
        <executions>
            <execution>
                <phase>generate-sources</phase>
                <goals>
                    <goal>java</goal>
                </goals>
                <configuration>
                    <classpathScope>compile</classpathScope>
                    <mainClass>com.vaadin.sass.SassCompiler</mainClass>
                    <arguments>
                        <argument>src/main/webapp/VAADIN/themes/heijunka/styles.scss</argument>
                        <argument>src/main/webapp/VAADIN/themes/heijunka/styles.css</argument>
                    </arguments>
                </configuration>
            </execution>
        </executions>
    </plugin>
    

    来源:http://dev.vaadin.com/ticket/10291

    【讨论】:

    • 感谢您的回复。它适用于 Maven 目标。我无法谷歌票。我猜是错误的关键字。无论如何,我讨厌在 Vaadin 中进行造型 :)
    • IVY 也有类似的简单解决方案吗?谢谢
    • 根据票证,vaadin-maven-plugin 中现在存在一个新的“compile-theme”目标,但在使用“mvn archetype:generate”生成项目时默认禁用它。
    【解决方案2】:

    @Develman 已经回答了如何解决该问题,但需要更多解释。

    当 Vaadin 应用程序处于开发模式时,它会在请求 styles.css 且文件不存在时自动进行 SCSS -> CSS 编译。在生产模式下,这不会发生。如果styles.css 存在,无论模式如何,都使用该文件并且没有SCSS -> CSS 编译。

    【讨论】:

    • 很高兴知道这一点。感谢您的澄清。
    【解决方案3】:

    即使我已将 maven 目标添加到 pom.xml,我也收到此错误 终于知道原因了,因为我在web.xml上启用了Vaadin的生产模式 所以当生产模式打开时,它不会生成styles.css 文件。 因此,您需要禁用生产模式才能启用此 SCSS -> CSS 编译。

    <context-param>
        <description>Vaadin production mode</description>
        <param-name>productionMode</param-name>
        <param-value>false</param-value>
    </context-param>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-03-25
      • 1970-01-01
      • 2021-06-01
      • 1970-01-01
      • 2021-01-26
      • 2018-12-13
      • 1970-01-01
      • 2019-05-26
      相关资源
      最近更新 更多