Maven 和 Cargo:使用 war-File 启动 Jetty-Container
我刚刚启动了一个新的 Maven 项目,该项目旨在启动一个包含来自依赖项目的 war 文件的 Jetty。货物插件应该是正确的工具。
不幸的是它对我不起作用。它成功启动了 Jetty,但它只包含 default-cargo-war-file,而不是预期的文件。
这是我的 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 [email protected]:7070
[INFO] [beddedLocalContainer] Jetty 7.x Embedded started on port [7070]
我如何告诉 Cargo 加载指定的 war 文件?
I just started a new Maven project that is intended to start a Jetty containing a war-File from a depended project. The cargo-plugin should be the right tool for this.
Unfortunately it doesn't work for me. It starts Jetty successfully but it only contains the default-cargo-war-file, not the expected one.
This is the relevant part of my 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>
I use the plugin by starting mvn cargo:start.
There is no error log output.
[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 [email protected]:7070
[INFO] [beddedLocalContainer] Jetty 7.x Embedded started on port [7070]
How can I tell Cargo to load the specified war-File?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
好的,我现在开始工作了。
看起来,cargo 会默默地忽略任何快照依赖项。所以你必须先发布一个项目,然后才能在货物项目中使用它。
可能这是一个错误。我无法想象这种行为有任何合理的理由。
(我上面发布的 pom 文件也不正确,您必须适应 Robin 在他的答案中建议的更改)
Ok, I got it to work now.
As it seems, cargo silently ignores any snapshot dependencies. So you have to release a project before using it in a cargo-project.
Probably this is a bug. I can't imagine any sensible reason for this behaviour.
(also the pom-File I posted above was not correct, you have to adapt the changes that Robin suggests in his answer)
试试这个。将您的配置类型设置为独立并将部署放入配置中。确保存在正确的项目依赖关系以解决战争。
Try this. Set your configuration type to standalone and put the deployables in the configuration. Make sure the correct project dependency exists to resolve the war.
如果您首先进行部署,例如运行命令“mvn Cargo:deploy”,然后运行“mvn Cargo:start”,那么它似乎可以更好地工作
Its seems it could work better if you first do the deployment say run a command "mvn cargo:deploy" then run a "mvn cargo:start"
如果您只想部署在嵌入式 Jetty 上,则可能不需要 Cargo。只需在您的网络应用程序的 pom.xml 中使用它即可:
构建并启动 Jetty 用户
If you just want to deploy on embedded Jetty, you may not need Cargo. Just use this, in your web-app's pom.xml:
to build and start Jetty user