简体   繁体   English

Maven,Vaadin和资源文件夹

[英]Maven, Vaadin and the resources folder

I have an existing maven project, in which i started to use vaadin, by adding the dependency in the POM file. 我有一个现有的maven项目,在其中开始通过在POM文件中添加依赖项来使用vaadin。 However, when i place the VAADIN/themes folder under src/main/resources, when building with maven it gets copied to the WEB-INF/classes folder in the .war file, instead of placing it in the war root like it is supposed to be. 但是,当我将VAADIN / themes文件夹放置在src / main / resources下时,使用maven进行构建时,它会被复制到.war文件中的WEB-INF / classes文件夹中,而不是像假定的那样放置在war根目录中成为。 I already tried all obvious combinations like src/main/webapp/VAADIN or src/main/VAADIN or even src/main/webapp/WEB-INF/VAADIN but none of them seems to be the correct place to put the themes and other vaadin resources. 我已经尝试了所有显而易见的组合,例如src / main / webapp / VAADIN或src / main / VAADIN甚至src / main / webapp / WEB-INF / VAADIN,但似乎没有一个是放置主题和其他vaadin的正确位置资源。

I also tried to generate a vaadin project like it is described in here https://vaadin.com/wiki/-/wiki/Main/Using%20Vaadin%20with%20Maven but no success. 我还尝试生成一个vaadin项目,如此处https://vaadin.com/wiki/-/wiki/Main/Using%20Vaadin%20with%20Maven中所述,但没有成功。 maven behaves in the same way. 专家的行为方式相同。

Does anyone have an idea of how to correctly setup Vaadin themes on a maven project ? 有谁知道如何在Maven项目上正确设置Vaadin主题? I am using osx 10.6 with maven 3 我在Maven 3中使用osx 10.6

Any help would be much appreciated. 任何帮助将非常感激。 Best Regards 最好的祝福

I'm not sure about Vaadin specifically, but you can use the Maven Resources plugin to copy resources to a specific place (anywhere you like, not just the target folder). 我不确定Vaadin的具体含义,但是您可以使用Maven资源插件将资源复制到特定位置(任意位置,而不仅仅是目标文件夹)。 So if you wanted to copy a folder called VAADIN from the root of your project to the root of your war, you could set it up like this: 因此,如果您要将一个名为VAADIN的文件夹从项目的根目录复制到战争的根目录,则可以这样设置:

<plugin>
  <artifactId>maven-resources-plugin</artifactId>
  <version>2.5</version>
  <executions>
    <execution>
      <id>copy-resources</id>
      <phase>validate</phase>
      <goals>
        <goal>copy-resources</goal>
      </goals>
      <configuration>
        <outputDirectory>${basedir}/target/war</outputDirectory>
        <resources>
          <resource>
            <directory>VAADIN</directory>
            <filtering>false</filtering>
          </resource>
        </resources>
      </configuration>
    </execution>
  </executions>
</plugin>

Generally the src/main/resources folder is intended for resources which are supposed to be on the classpath, and src/main/webapp is for resources which are supposed to be in the WEB-INF folder of your webapp. 通常, src/main/resources文件夹用于应放在类路径中的资源,而src/main/webapp用于应放在Webapp的WEB-INF文件夹中的资源。 I'd recommend putting other resources elsewhere (maybe src/main/vaadin ?). 我建议将其他资源放在其他地方(也许是src/main/vaadin ?)。 If you do really want to put it in src/main/resources and you use the approach I've just outlined, you'll also need to exclude it Maven copies the other things in there - easier just to avoid it. 如果您确实想将其放在src/main/resources并且使用我刚才概述的方法,则还需要排除它,Maven会在其中复制其他内容-避免它更容易。

您应该将src / main / webapp /中放置的所有内容都置于战争的根源,而无需进行任何自定义。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM