【问题标题】:Maven Tomcat (embedded )Maven Tomcat(嵌入式)
【发布时间】:2015-06-21 18:27:48
【问题描述】:

我正在尝试通过 tomcat maven 插件将战争部署到嵌入式 tomcat 服务器。控制台显示服务器启动正常。

看来战争没有展开。当我访问 http://localhost:9090/foohttp://localhost:9090 时,我从 Tomcat 获得 HTTP 状态 404

我在 target/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:run 的输出

[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"]

【问题讨论】:

    标签: maven tomcat


    【解决方案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://localhost:9090/foohttp://localhost:9090时你得到HTTP Status 404

    您正在查看控制台日志,但查看访问日志可能会为您提供更多相关信息。 在此处查看有关 tomcat 日志的更多信息:https://tomcat.apache.org/tomcat-8.0-doc/logging.html

    【讨论】:

    • 感谢您的回复。我放弃了并采用了不同的方法,但我会尝试你的建议。
    猜你喜欢
    • 2010-11-25
    • 2023-03-05
    • 2019-03-23
    • 2012-06-11
    • 2014-03-07
    • 1970-01-01
    • 1970-01-01
    • 2012-11-04
    • 1970-01-01
    相关资源
    最近更新 更多