2012-11-18 39 views
1

我正在從這個碼頭Maven插件有點沮喪的jetty.xml ..碼頭Maven插件忽略我無緣無故

我想配置碼頭 - Maven的插件與我的jetty.xml文件。 ( 見下文 )。

我希望碼頭,開始對端口8081

但是我一直在當我運行控制檯獲得8080

mvn jetty:run 

我也希望看到一個日誌打印

Configuring Jetty from xml configuration file 

我在jetty-maven插件來源中找到的。但我沒有看到它。

我驗證了所有的文件都在正確的位置,並且我嘗試了很多變化的配置。

我的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> 

我看了幾乎所有的資源可能包括所有計算器Q值& A. 我必須失去了一些東西。

即使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); 
    } 

而且我加入實施吸氣

public File getJettyXmlFile() 
{ 
    return this.jettyConfig; 
} 

因此,我希望至少看到打印Configuring Jetty from xml... - 但事實並非如此也出現..

我設法從命令行覆蓋端口,但我對XML配置感興趣。

回答

0

如果您仍在追求此目標,可以嘗試http://wiki.eclipse.org/Jetty/Feature/Jetty_Maven_Plugin兩件事情。

1)「你一定是明確的加入對碼頭,servlet的依賴使碼頭的擴展名」

<plugin> 
... 
    <dependency> 
     <groupId>org.eclipse.jetty</groupId> 
     <artifactId>jetty-server</artifactId> 
     <version>7.2.0.v20101020</version> 
    </dependency> 
</plugin> 

2)如果你做第1步,通過將其指示在適當的groupId的Maven(該組織.mortbay.jetty,而不是org.eclipse.jetty)設置。XML

<profile> 
     ... 
    <pluginGroups> 
     <pluginGroup>org.mortbay.jetty</pluginGroup> 
    </pluginGroups> 
</profile> 
+0

哇,謝謝。我一定會盡快回復。我目前正在追求別的東西,但這個問題仍然存在,所以我仍然需要關閉它。 –

0

你應該嘗試的的artifactId從

<artifactId>maven-jetty-plugin</artifactId>

改變

<artifactId>jetty-maven-plugin</artifactId>

因爲你的jetty.xml使用的類與org.eclipse前綴。jetty with jetty 7

1

重命名爲jettyConfigwebAppXml