[英]Platform dependent .war-file produced with maven and Jersey/Jackson setting?
[英]Maven and Cargo: start Jetty-Container with war-File
我剛剛開始了一個新的Maven項目,該項目旨在啟動包含來自依賴項目的war-File的Jetty。 貨物插件應該是正確的工具。
不幸的是,它對我不起作用。 它成功啟動了Jetty,但它只包含default-cargo-war-file,而不是預期的文件。
這是我的戰爭文件的相關部分:
<dependencies>
<dependency>
<groupId>com.group</groupId>
<artifactId>my-webapp</artifactId>
<version>0.1.0-SNAPSHOT</version>
<type>war</type>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.0.5</version>
<configuration>
<container>
<containerId>jetty7x</containerId>
<type>embedded</type>
</container>
<configuration>
<properties>
<cargo.servlet.port>7070</cargo.servlet.port>
<cargo.logging>high</cargo.logging>
</properties>
</configuration>
<deployer>
<type>embedded</type>
<deployables>
<deployable>
<groupId>com.group</groupId>
<type>war</type>
<artifactId>my-webapp</artifactId>
<properties>
<context>/path</context>
</properties>
</deployable>
</deployables>
</deployer>
</configuration>
</plugin>
</plugins>
</build>
我通過啟動mvn cargo:start來使用插件。
沒有錯誤日志輸出。
[INFO] [cargo:start]
[INFO] [beddedLocalContainer] Jetty 7.x Embedded starting...
2011-01-17 18:57:44.586:INFO::jetty-7.2.0.v20101020
2011-01-17 18:57:44.663:INFO::Extract jar:file:/tmp/cargo/conf/cargocpc.war!/ to /tmp/jetty-0.0.0.0-7070-cargocpc.war-_cargocpc-any-/webapp
2011-01-17 18:57:45.082:INFO::Started SelectChannelConnector@0.0.0.0:7070
[INFO] [beddedLocalContainer] Jetty 7.x Embedded started on port [7070]
如何告訴Cargo加載指定的war-File?
好的,我現在就開始工作了。
看起來,貨物默默地忽略任何快照依賴。 因此,您必須在貨物項目中使用之前發布項目。
可能這是一個錯誤。 我無法想象這種行為有任何明智的原因。
(也是我上面發布的pom-File不正確,你必須調整Robin在他的答案中建議的變化)
試試這個。 將配置類型設置為獨立 ,並將可部署的內容放入配置中。 確保存在正確的項目依賴關系來解決戰爭。
<configuration>
<type>standalone</type>
<properties>
<cargo.servlet.port>7070</cargo.servlet.port>
<cargo.logging>high</cargo.logging>
</properties>
<deployables>
<deployable>
<groupId>com.group</groupId>
<type>war</type>
<artifactId>my-webapp</artifactId>
<properties>
<context>/path</context>
</properties>
</deployable>
</deployables>
</configuration>
它似乎可以更好地工作如果你第一次部署說運行命令“mvn cargo:deploy”然后運行“mvn cargo:start”
如果您只想在嵌入式Jetty上部署,則可能不需要Cargo。 只需在您的web-app的pom.xml中使用它:
<build>
...
...
<plugins>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>7.2.2.v20101205</version>
<configuration>
<scanIntervalSeconds>10</scanIntervalSeconds>
<webAppConfig>
<contextPath>/path</contextPath>
</webAppConfig>
<connectors>
<connector implementation="org.eclipse.jetty.server.nio.SelectChannelConnector">
<port>7070</port>
<maxIdleTime>60000</maxIdleTime>
</connector>
</connectors>
</configuration>
</plugin>
...
...
</plugins>
...
...
</build>
構建並啟動Jetty用戶
mvn clean install jetty:run
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.