【问题标题】:Spring Vaadin theme春季 Vaadin 主题
【发布时间】:2017-04-23 18:16:42
【问题描述】:

您好,我正在使用 spring boot 和 vaadin 为大学创建一个 webapp。我想要做的就是改变背景颜色。通过添加 src/man/webapp/VAADIN/themes/myTheme

然后我有

myTheme.scss

@import "../valo/valo";

@mixin myTheme {
  @include valo;

}

我也试过 valo.scss

styles.scss

@import "mytheme.scss";


.mytheme {
  @include mytheme;
}

然后我在我的 ui 中调用 @theme,但我得到一个编译错误,我已经尝试了各种方法来解决这个问题。

valo 文件夹好像是空的

堆栈跟踪

INFO] --- vaadin-maven-plugin:8.0.5:compile-theme (default) @ book-reviews ---
[INFO] Updating theme VAADIN/themes/myTheme
[ERROR] Apr 23, 2017 7:14:39 PM com.vaadin.sass.internal.handler.SCSSErrorHandler severe
[ERROR] SEVERE: Mixin Definition: mytheme not found
[ERROR] Compiling theme "VAADIN/themes/myTheme" failed
org.codehaus.mojo.gwt.shell.JavaCommandException: Command [[
/bin/sh -c '/Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home/jre/bin/java' '-Xmx512M' '-Xss1024k' 'com.vaadin.sass.SassCompiler' '/Users/teamwork/Documents/book-reviews/src/main/webapp/VAADIN/themes/myTheme/styles.scss' '/Users/teamwork/Documents/book-reviews/src/main/webapp/VAADIN/themes/myTheme/styles.css'
]] failed with status 1
    at org.codehaus.mojo.gwt.shell.JavaCommand.execute(JavaCommand.java:330)
    at com.vaadin.integration.maven.CompileThemeMojo.processTheme(CompileThemeMojo.java:65)
    at com.vaadin.integration.maven.AbstractThemeMojo.doExecute(AbstractThemeMojo.java:43)
    at org.codehaus.mojo.gwt.shell.AbstractGwtShellMojo.execute(AbstractGwtShellMojo.java:182)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
    at org.codehaus.classworlds.Launcher.main(Launcher.java:47)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.208 s
[INFO] Finished at: 2017-04-23T19:14:39+01:00
[INFO] Final Memory: 24M/437M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.vaadin:vaadin-maven-plugin:8.0.5:compile-theme (default) on project book-reviews: Compiling theme "VAADIN/themes/myTheme" failed: Command [[
[ERROR] /bin/sh -c '/Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home/jre/bin/java' '-Xmx512M' '-Xss1024k' 'com.vaadin.sass.SassCompiler' '/Users/teamwork/Documents/book-reviews/src/main/webapp/VAADIN/themes/myTheme/styles.scss' '/Users/teamwork/Documents/book-reviews/src/main/webapp/VAADIN/themes/myTheme/styles.css'
[ERROR] ]] failed with status 1
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.book-center</groupId>
    <artifactId>book-reviews</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>book-reviews</name>
    <description>Demo project for Spring Boot</description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.2.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jdbc</artifactId>
        </dependency>

        <dependency>
            <groupId>com.vaadin</groupId>
            <artifactId>vaadin-spring-boot-starter</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <scope>runtime</scope>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>com.vaadin</groupId>
            <artifactId>vaadin-client-compiler</artifactId>
            <scope>provided</scope>
        </dependency>


    </dependencies>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>com.vaadin</groupId>
                <artifactId>vaadin-bom</artifactId>
                <version>8.0.5</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>

        </dependencies>
    </dependencyManagement>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>com.vaadin</groupId>
                <artifactId>vaadin-maven-plugin</artifactId>
                <configuration>
                    <extraJvmArgs>-Xmx512M -Xss1024k</extraJvmArgs>
                    <noServer>true</noServer>
                    <webappDirectory>${basedir}/src/main/webapp/VAADIN/widgetsets</webappDirectory>
                    <hostedWebapp>${basedir}/src/main/webapp/VAADIN/widgetsets</hostedWebapp>
                    <!-- Remove draftCompile when project is ready -->
                    <draftCompile>false</draftCompile>
                    <compileReport>true</compileReport>
                    <style>OBF</style>
                    <strict>true</strict>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <!--<goal>clean</goal>-->
                            <goal>resources</goal>
                            <goal>update-widgetset</goal>
                            <goal>compile</goal>
                            <goal>update-theme</goal>
                            <goal>compile-theme</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>


    </build>


</project>

有人可以帮助我吗?我真的不喜欢使用它。谢谢

【问题讨论】:

  • 也许我的帖子sothawo.com/2015/06/… 可以提供帮助。对不起,这个简短的答案,但我在路上用我的手机
  • 我猜 src/**main**/webapp 是不是问题?
  • @SteffenHarbich 对不起,我在这里拼错了,但不是在那里。

标签: java spring maven vaadin


【解决方案1】:

您需要注意styles.scss 中的字符大小写。应该是这样的:

@import "myTheme.scss";

.myTheme {
  @include myTheme;
}

注意大写的“T”。还要确保您的 UI 类带有以下注释:

@Theme("myTheme")

另请注意,您不需要valo 文件夹,也不会在您的项目中创建或填充一个文件夹。导入的 valo SCSS 文件和包含的 valo mixin 打包在 vaadin-themes jar 中。

祝你好运。

【讨论】:

    【解决方案2】:

    尝试在 src/main/resources/VAADIN/themes/yourtheme 中添加主题

    问候

    【讨论】:

      猜你喜欢
      • 2021-08-10
      • 1970-01-01
      • 2016-09-07
      • 2015-07-25
      • 2011-10-19
      • 1970-01-01
      • 2016-06-29
      • 2016-12-14
      • 1970-01-01
      相关资源
      最近更新 更多