2017-04-23 51 views
1

您好,我正在使用spring boot和vaadin为大学创建一个webapp。我想要做的就是改变背景颜色。通过添加的src /人/ web应用/ VAADIN /主题/ mytheme的Spring Vaadin主题

,然后我有

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> 

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

+1

也许我的文章https://www.sothawo.com/2015/06/custom-theme-for -a-vaadin-spring-boot-application /可以提供帮助。对不起,gor这个简短的答案,但我在路上使用我的手机 –

+0

我猜src/** main **/webapp不是问题吗? –

+0

@SteffenHarbich对不起,我在这里拼写错了,但没有。 –

回答

1

您需要在您的styles.scss中观看字符大小写。它应该如下:

@import "myTheme.scss"; 

.myTheme { 
    @include myTheme; 
} 

注意大写“T”。另外,还要确保你的UI类都被注解:

@Theme("myTheme") 

还要注意的是,你并不需要一个valo文件夹,也不会一个创建或您的项目中填充。进口的valo SCSS文件和Valo mixin包装在vaadin-themes罐子中。

祝你好运。

0

尝试添加主题的src /主/资源/ VAADIN /主题/ yourtheme

问候