我有一个Vaadin 7 maven web项目,它有一些注释,可以在META-INF/services
上创建服务定义。
我将其添加到pom中,以便处理注释:
<!-- Run annotation processors on src/main/java sources -->
<plugin>
<groupId>org.bsc.maven</groupId>
<artifactId>maven-processor-plugin</artifactId>
<version>3.3.1</version>
<executions>
<execution>
<id>process</id>
<goals>
<goal>process</goal>
</goals>
<phase>generate-sources</phase>
</execution>
</executions>
</plugin>
这些文件显示在target/classes/META-INF/services
中,但不能进入最后的战争。
我尝试将文件夹添加到maven-war插件中,如下所示:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
<packagingIncludes>target/classes/*</packagingIncludes>
</configuration>
</plugin>
但是,大多数Vaadin文件没有进入战争,也无法工作。有什么想法吗?
发布于 2017-04-21 13:58:21
最后,我使用了这个不相关的答案:Maven: include folder in resource folder in the war build。
以下是我最后所做的:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
<webResources>
<resource>
<directory>target/classes/META-INF/services</directory>
<includes>
<include>*.*</include>
</includes>
<targetPath>META-INF/services</targetPath>
</resource>
</webResources>
</configuration>
</plugin>
基本上,将“服务”文件夹添加为资源,并将其放在最后一次战争的正确位置。
发布于 2017-04-21 20:14:22
请参阅https://maven.apache.org/plugins/maven-war-plugin/usage.html
看起来您的META-INF
文件夹位于src/main/resources
目录中。
通常,在创建WAR
时,您将创建一个目录src/main/webapp
,您可以在其中拥有WEB-INF
、META-INF
和其他所需的文件夹。
|-- src
| `-- main
| |-- java
| | `-- com
| | `-- example
| | `-- projects
| | `-- SampleAction.java
| |-- resources
| | `-- images
| `-- webapp
| |-- META-INF
| |-- WEB-INF
您的webapp
文件夹中的所有内容都将复制到WAR
中的根dir。
还可以使用warSourceDirectory属性配置到webapp
的路径。
为您的方案生成的源。
显然,您不希望将生成的源保存在src/*
文件夹中,也不希望对其进行版本化。
您可以通过向版本控制元数据中添加一个忽略筛选器,或者通过创建一个符号链接,或者像前面的一些答案所说的那样使用copy-resources
,但不建议这样做。
您可以通过添加webResources
配置来从target
文件夹复制生成的源,从而实现此目的。
请参阅http://maven.apache.org/plugins/maven-war-plugin/examples/adding-filtering-webresources.html
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<webResources>
<resource>
<directory>${project.build.directory}/target/generated-sources</directory>
<targetPath>META-INF</targetPath> <!-- introduced in plugin v 2.1 -->
<includes>
<include>*.class</include>
</includes>
</resource>
</webResources>
</configuration>
</plugin>
发布于 2017-04-21 11:07:38
你可以试试这个:
<execution>
<id>process</id>
<phase>generate-sources</phase>
<goals>
<goal>process</goal>
</goals>
<configuration>
<finalName>${projectId}</finalName>
<outputDirectory>relative project directory</outputDirectory>
<includes>
<include>path</include>
</includes>
</configuration>
</execution>
https://stackoverflow.com/questions/43373082
复制相似问题