【发布时间】:2012-11-18 14:59:04
【问题描述】:
我对这个 Jetty Maven 插件感到有点沮丧..
我正在尝试使用我的 jetty.xml 文件配置 jetty-maven-plugin。 ( 见下文 )。
我希望 Jetty 在端口 8081 上启动。
但是当我运行时,我在控制台中不断收到 8080
mvn jetty:run
我也希望看到日志打印
Configuring Jetty from xml configuration file
我在 jetty-maven-plugin 资源中找到的。但我在任何地方都没有看到它。
我验证了所有文件都在正确的位置,并且到目前为止我尝试了许多不同的配置。
我的 Maven 配置是:
...
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>${jettyVersion}</version>
<configuration>
<jettyConfig>${project.basedir}/src/main/resources/jetty.xml</jettyConfig>
</configuration>
</plugin>
.....
<properties>
<jettyVersion>7.2.0.v20101020</jettyVersion>
</properties>
我的 jetty.xml 文件是:
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">
<Configure id="Server" class="org.eclipse.jetty.server.Server">
<Call name="addConnector">
<Arg>
<New class="org.eclipse.jetty.server.nio.SelectChannelConnector">
<Set name="host"><SystemProperty name="jetty.host" /></Set>
<Set name="port"><SystemProperty name="jetty.port" default="8081"/></Set>
<Set name="maxIdleTime">300000</Set>
<Set name="Acceptors">4</Set>
<Set name="statsOn">false</Set>
<Set name="confidentialPort">8443</Set>
<Set name="lowResourcesConnections">20000</Set>
<Set name="lowResourcesMaxIdleTime">5000</Set>
</New>
</Arg>
</Call>
</Configure>
我阅读了几乎所有可能的资源,包括 stackoverflow 的所有问答。 我肯定错过了什么。
尽管 Eclipse 在 POM 中将 jetty.xml 的配置参数记录为“jettyXml”,但我还是下载了它们的源代码。它绝对是“jettyConfig”。
查看他们的代码,我看到以下内容
public void applyJettyXml() throws Exception
{
if (getJettyXmlFile() == null)
return;
getLog().info( "Configuring Jetty from xml configuration file = " + getJettyXmlFile() );
XmlConfiguration xmlConfiguration = new XmlConfiguration(getJettyXmlFile().toURL());
xmlConfiguration.configure(this.server);
}
我正在添加 getter 的实现
public File getJettyXmlFile ()
{
return this.jettyConfig;
}
所以我希望至少能看到打印 Configuring Jetty from xml... - 但它也没有出现..
我设法从命令行覆盖了端口,但我对 XML 配置感兴趣。
【问题讨论】: