更新时间:2022-10-31 16:54:19
回答了我自己的问题.
将maven-jetty-plugin升级到至少6.1.12
Upgrade maven-jetty-plugin to at least 6.1.12
请参阅此Wiki页面上的配置多个Web应用程序源目录"(自jetty-6.1.12.rc2和jetty-7.0.0pre3起可用)
See this wiki page on 'Configuring Multiple WebApp Source Directory' (available since jetty-6.1.12.rc2 and jetty-7.0.0pre3)
向pom.xml添加一些魔术:
Add some magic to pom.xml:
首先,为过滤后的网络资源添加一个新目录(src/main/webResources),并添加一个< resource>元素:
First, add a new directory (src/main/webResources) for your filtered web resources and add a <resource> element:
<resource>
<directory>src/main/webResources</directory>
<filtering>true</filtering>
<targetPath>../jettyFilteredResources</targetPath>
</resource>
这会将文件复制到target/jettyFilteredResources(我们将在以后引用).此目录不会复制到打包的WAR文件中,仅用于码头!
That will copy the files to target/jettyFilteredResources (we will reference this later). This directory will NOT get copied to your packaged WAR file, it is for jetty only!
在您的maven-war-plugin< configuration>中添加以下元素元素:
Add the following element to your maven-war-plugin <configuration> element:
<webResources>
<resource>
<directory>src/main/webResources</directory>
<filtering>true</filtering>
</resource>
</webResources>
这将确保为您的真实WAR文件打包所有内容.
That will ensure everything is packaged up for your real WAR file.
最后,通过将以下代码段添加到您的< baseResource>中,告诉Jetty使用您专门为其复制的资源.元素:
Finally, tell jetty to use the resources your copied especially for it, by added the following snippet to your <baseResource> element:
<baseResource implementation="org.mortbay.resource.ResourceCollection">
<resourcesAsCSV>src/main/webapp,target/jettyFilteredResources</resourcesAsCSV>
</baseResource>
现在一切都会正常! (嗯,从技术上讲,我还没有测试过生产中的战争,但是……等等……它也应该工作).
Now everything will worketh! (Well, technically I haven't tested the production WAR yet, but ... blah ... it should work too).
如果有人有更好的答案,只要在合理的时间内(例如1天)提供了答案,我就会接受.
If anyone has a better answer, I will accept it provided the answer is provided in a reasonable amount of time (say 1 day).