如果可能,我想將Tomcat的context.xml文件放在我的WAR文件的META-INF目錄中。這可以用Maven的貨物插件完成嗎?我似乎無法找到正確的配置。是否可以通過Maven Cargo插件提供Tomcat6的context.xml文件?
回答
尤里卡!經過多天研究這個問題,我終於找到了一個非常有效的解決方案。關鍵是要取出Tomcat XML上下文片段文件,並使用<configfiles>
元素的貨物將其放入名稱爲context.xml.default
的conf/Catalina/localhost
目錄中。唯一的缺點是這會讓你的上下文定義可用於所有的網絡應用程序,但這只是貨真價實的,因爲沒有其他的網絡應用程序。
這裏的配置:
<configuration> <!-- Deployer configuration -->
<type>standalone</type>
<properties>
<cargo.servlet.port>${tomcat6.port}</cargo.servlet.port>
</properties>
<deployables>
<deployable>
<groupId>com.myapp<groupId>
<artifactId>myapp-war</artifactId>
<type>war</type>
<properties>
<context>${tomcat6.context}</context>
</properties>
</deployable>
</deployables>
<configfiles>
<configfile>
<file>${basedir}/../config/tomcat-context.xml</file>
<todir>conf/Catalina/localhost/</todir>
<tofile>context.xml.default</tofile>
</configfile>
</configfiles>
</configuration>
最終的結果是沒有更多的假WAR模塊僅用於測試,和戰爭沒有更多的合併。希望這有助於某人。
我還沒有找到辦法做到這一點,但我想出了一個解決方案,在我的項目中工作。我目前有基本3子模塊項目:
dependencies
webapp
smoketest
當我正在創建的「Web應用」項目,我執行以下插件聲明:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<executions>
<execution>
<id>create-war-smoketest</id>
<phase>verify</phase>
<goals>
<goal>war</goal>
</goals>
<configuration>
<webappDirectory>${project.build.directory}/exploded</webappDirectory>
<primaryArtifact>false</primaryArtifact>
<classifier>smoketest</classifier>
<webResources>
<resource>
<filtering>true</filtering>
<directory>src/test/resources/smoketest</directory>
<targetPath>META-INF</targetPath>
<includes>
<include>context.xml</include>
</includes>
</resource>
</webResources>
</configuration>
</execution>
</executions>
</plugin>
然後當我跑步時我貨運/ WebTest的套件在SmokeTest項目中,我指定的smoketest WAR文件作爲依賴,並在我的貨物配置設置我deployrables正是如此:
<deployables>
<deployable>
<groupId>${pom.groupId}</groupId>
<artifactId>webapp</artifactId>
<type>war</type>
<properties>
<context>smoketest</context>
</properties>
</deployable>
</deployables>
有了依賴性升舉個例子:
<dependencies>
<dependency>
<groupId>${pom.groupId}</groupId>
<artifactId>webapp</artifactId>
<version>${pom.version}</version>
<classifier>smoketest</classifier>
<type>war</type>
<scope>system</scope>
<!-- trick the dependency plugin to never look for it in the repo -->
<systemPath>${basedir}/../webapp/target/webapp-${pom.version}-smoketest.war</systemPath>
</dependency>
</dependencies>
這是非常骯髒的,但它至少可以......現在。一個簡單的說明:關於強制它從不在回購中查找版本的評論在這一點上可能是不正確的;我認爲這個技巧可能在某些時候被依賴插件的改變破壞了。
我也試過這個 - 它對我也適用。只是希望免除一次性WAR工件 - 因爲我們不希望/不能在其中發佈帶有過濾的context.xml文件的WAR。 – HDave 2010-11-30 03:08:09
- 1. Maven cargo jetty6x:是否可以提供額外的碼頭配置?
- 2. 是否可以通過dotnet核心(即Kestrel)提供.aspx文件?
- 3. maven貨物插件與tomcat6
- 4. 是否可以通過grgit插件提交gradle只有一個文件?
- 5. 是否可以通過JavaScript檢測插件是否被激活?
- 6. 是否可以爲AddThis插件提供自定義網址?
- 7. 是否可以拆分maven pom文件?
- 8. maven插件如何向另一個文件提供文件?
- 9. 是否可以在運行時提供新的PropertiesConfiguration文件?
- 10. 安裝Maven插件時是否可以運行maven artifact?
- 11. 是否可以通過USB通過ZModem傳輸文件?
- 12. 通過文件給可運行jar文件提供輸入
- 13. 是否可以從XML文件提供數據庫表?
- 14. Maven JarJar插件:排除'提供'範圍?
- 15. 閱讀通過$ _GET提供的文件
- 16. 如何通過Maven插件
- 17. 是否有可能通過nfs mount來爲nginx/ubuntu提供靜態文件?
- 18. 有人可以通過S3來源通過Cloudfront從Cloudfront提供gzip文件嗎?
- 19. Tomcat context.xml文件,是否有hiearchy?
- 20. WordPress是否以Joomla的方式提供插件覆蓋功能?
- 21. Tomcat6忽略META-INF/context.xml
- 22. 是否可以通過腳本禁用IE Lync插件
- 23. 是否可以通過插件在佔位符內循環?
- 24. 是否可以通過PHP爲WHM編寫插件?
- 25. 是否可以使用文件過濾器過濾生成的Maven EAR插件application.xml?
- 26. JS文件不通過HTTPS提供
- 27. django:通過nginx提供靜態文件
- 28. 是否可以通過串口通過PuTTY發送文本文件的內容?
- 29. 叢編注解是否可以在Maven插件中使用?
- 30. 是否可以使用revapi maven插件來檢查SNAPSHOT版本?
它工作除了貨物1.1.1接縫不添加新文件的事實。我只能替換文件。 – Ralph 2011-06-24 13:34:24