我正在使用 cargo 插件来配置 Tomcat。但我无法启动我的应用程序。在点击应用程序 URL 时获得 400。
pom.xml 中的 cargo 配置如下所示:
<plugin>
<!-- Load config files into the target/tomcat/conf directory.
Placeholder are resolved. The Cargo plugin definition below
tells Tomcat to use this directory. -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.4.2</version>
<executions>
<execution>
<id>configure-tomcat</id>
<phase>integration-test</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}</outputDirectory>
<overwrite>true</overwrite>
<filters>
<filter>${config.properties}</filter>
</filters>
<resources>
<resource>
<!-- the https-connector.temp file -->
<directory>${basedir}/src/test/resources/tomcat</directory>
<filtering>true</filtering>
<includes>
</includes>
<targetPath>${project.build.directory}/tomcat/conf</targetPath>
</resource>
<resource>
<!-- server.xml, logback.xml, etc -->
<directory>${basedir}/../installer/tomcat</directory>
<filtering>true</filtering>
<includes>
</includes>
<targetPath>${project.build.directory}/tomcat/conf</targetPath>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.6.4</version>
<configuration>
<container>
<containerId>tomcat8x</containerId>
<zipUrlInstaller>
<url>https://repo1.maven.org/maven2/org/apache/tomcat/tomcat/8.5.20/tomcat-8.5.20.zip</url>
</zipUrlInstaller>
<systemProperties>
<!-- these result in -D arguments -->
<user.timezone>GMT</user.timezone>
<logback.configurationFile>file://${basedir}/../installer/tomcat/logback.xml</logback.configurationFile>
<config.properties>${config.properties}</config.properties>
<java.awt.headless>true</java.awt.headless>
<project.build.finalName>${project.build.finalName}</project.build.finalName>
<doc.root>${doc.root}</doc.root>
<java.net.preferIPv4Stack>false</java.net.preferIPv4Stack>
<version>${VERSION}</version>
<build>${BUILD_NUMBER}</build>
</systemProperties>
</container>
<configuration>
<home>${project.build.directory}/catalina-base</home>
<type>standalone</type>
<properties>
<!-- hostname and servlet.port are overridden in our custom server.xml
They seem to be used only for the ping URL -->
<cargo.hostname>localhost</cargo.hostname>
<cargo.servlet.port>4080</cargo.servlet.port>
<cargo.protocol>http</cargo.protocol>
<cargo.logging>high</cargo.logging>
<cargo.rmi.port>4005</cargo.rmi.port>
</properties>
<files>
<file>
<!-- the file element also works for directories.
The source directory contains server.xml
and the usual config files, with placeholders resolved -->
<file>${project.build.directory}/tomcat/conf</file>
<todir>conf</todir>
<configfile>true</configfile>
<overwrite>true</overwrite>
</file>
</files>
</configuration>
<deployables>
<deployable>
<location>${project.build.directory}/abc.war</location>
<type>war</type>
</deployable>
</deployables>
<packager>
<outputLocation>${project.build.directory}/tomcat-packaged</outputLocation>
</packager>
</configuration>
<executions>
<execution>
<id>start</id>
<phase>integration-test</phase>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
在点击 URL http://localhost:4080/cargocpc/index.html时,我得到了货物主页。但是在点击http://localhost:4080/abc时,我得到了 400。
如我所见,下面提到的目标文件夹的结构,abc 文件夹(abc 是我的应用程序的名称)在目标内部与 catalina-base 平行扩展,但 cargocpc 在 /catalina-base/webapps 内部扩展。
webapps中没有abc文件夹可以成为400 Bad request的原因吗?
配置有什么问题吗?如果 abc 文件夹应该在 webapps 中展开,应该做哪些配置?