2015-04-15 142 views
1

我試圖通過tomcat maven插件將戰爭部署到嵌入式tomcat服務器。控制檯顯示服務器啓動正常。Maven Tomcat(嵌入式)

看來這場戰爭沒有部署。我得到一個HTTP狀態404從Tomcat,當我訪問http://localhost:9090/foohttp://localhost:9090

我看到目標/ tomcat的沒有戰爭文件或展開的戰爭文件/ webapps中

我的配置是有點(非常)非標準由於一些因素超出我的控制範圍:

  • 該項目使用除Maven之外的其他方式構建war文件。
  • 該項目沒有按照Maven標準進行設置。
  • 該項目有一個包裝類型的POM。

POM:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 
    <groupId>com.foo</groupId> 
    <artifactId>foo</artifactId> 
    <version>0.0.1-SNAPSHOT</version> 
    <packaging>pom</packaging> 
    <name>iCON</name> 
    <build> 
     <plugins> 
      <plugin> 
       <groupId>org.apache.tomcat.maven</groupId> 
       <artifactId>tomcat7-maven-plugin</artifactId> 
       <version>2.2</version> 
       <configuration> 
        <ignorePackaging>true</ignorePackaging> 
        <warFile>foo.war</warFile> 
        <port>9090</port> 
       </configuration> 
      </plugin> 
     </plugins> 
    </build> 
</project> 

輸出的MVN tomcat7:運行

[INFO] Scanning for projects... 
[INFO] 
[INFO] ------------------------------------------------------------------------ 
[INFO] Building foo 0.0.1-SNAPSHOT 
[INFO] ------------------------------------------------------------------------ 
[INFO] 
[INFO] >>> tomcat7-maven-plugin:2.2:run (default-cli) > process-classes @ foo >>> 
[INFO] 
[INFO] <<< tomcat7-maven-plugin:2.2:run (default-cli) < process-classes @ foo <<< 
[INFO] 
[INFO] --- tomcat7-maven-plugin:2.2:run (default-cli) @ foo --- 
[INFO] Running war on http://localhost:9090/foo 
[INFO] Creating Tomcat server configuration at C:\someDir\aProject\target\tomcat 
[INFO] create webapp with contextPath: /foo 
Apr 15, 2015 12:50:56 PM org.apache.coyote.AbstractProtocol init 
INFO: Initializing ProtocolHandler ["http-bio-9090"] 
Apr 15, 2015 12:50:56 PM org.apache.catalina.core.StandardService startInternal 
INFO: Starting service Tomcat 
Apr 15, 2015 12:50:56 PM org.apache.catalina.core.StandardEngine startInternal 
INFO: Starting Servlet Engine: Apache Tomcat/7.0.47 
Apr 15, 2015 12:50:58 PM org.apache.coyote.AbstractProtocol start 
INFO: Starting ProtocolHandler ["http-bio-9090"] 

回答

1

我設法部署上使用相同的插件,你幾個星期前,一個嵌入式的Tomcat的戰爭。

我的配置如下

<build> 
<finalName>MSHAService</finalName> 
<plugins> 
    <plugin> 
    <groupId>org.apache.tomcat.maven</groupId> 
    <artifactId>tomcat7-maven-plugin</artifactId> 
    <version>2.2</version> 
    <configuration> 
     <url>http://localhost:8080/manager/text</url> 
     <server>localhost</server> 
     <path>/MSHA</path> 
     <username>user-acc-in-tomcat</username> 
     <password>some-password</password> 
    </configuration> 
    </plugin> 
</plugins> 

你可能會錯過一些從配置參數。

而且,你說你HTTP Status 404當您訪問http://localhost:9090/foohttp://localhost:9090

您正在尋找在控制檯日誌,但在尋找訪問日誌可能會給你更多這方面的信息。 查看更多about tomcat日誌在這裏:https://tomcat.apache.org/tomcat-8.0-doc/logging.html

+0

感謝您的回覆。我放棄了,採取了不同的方式,但我會嘗試一下你的建議。 – AfterWorkGuinness