部署为 ROOT 和 SpringLoaded Hippo CMS

Deploy as ROOT and SpringLoaded Hippo CMS

Spring 在我最近切换到以 root 身份部署之前,Loaded 对我来说一直运行良好。 (完全去掉我网站 URL 中的“/site”)

我已经修改了 Jeroen 在这里提出的原始配置,但它不起作用。 (${project.basedir}/target/tomcat7x/webapps/ROOT 下的文件未更新,网站指的是这个过时的来源而不是最新的 ${project.basedir}/site/target/ROOT

我错过了什么?

我的${project.basedir}/pom.xml:

<profile>
  <id>cargo.run</id>
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-resources-plugin</artifactId>
        <executions>
          <execution>
            <id>copy-tomcat-resources</id>
            <phase>validate</phase>
            <goals>
              <goal>copy-resources</goal>
            </goals>
            <configuration>
              <outputDirectory>${project.build.directory}/contexts</outputDirectory>
              <resources>
                <resource>
                  <directory>conf</directory>
                  <includes>
                    <include>*-context.xml</include>
                  </includes>
                  <filtering>true</filtering>
                </resource>
              </resources>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.codehaus.cargo</groupId>
          <artifactId>cargo-maven2-plugin</artifactId>
          <configuration>
            <configuration>
              <properties>
                <cargo.jvmargs>-Xmx1920m -Xdebug -Xrunjdwp:transport=dt_socket,address=${cargo.debug.address},server=y,suspend=${cargo.debug.suspend} -noverify -javaagent:/Users/eric/libs/springloaded.jar ${cargo.jvm.args}</cargo.jvmargs>
              </properties>
              <configfiles>
                <configfile>
                  <file>${project.build.directory}/contexts/site-context.xml</file>
                  <todir>conf/Catalina/localhost/</todir>
                  <tofile>site.xml</tofile>
                </configfile>
              </configfiles>
            </configuration>
          </configuration>
        </plugin>
      ...
    </plugins>
  </build>
</profile>

我的${project.basedir}/site/pom.xml

<finalName>ROOT</finalName>
...
<plugin>
        <groupId>com.googlecode.mavenfilesync</groupId>
        <artifactId>maven-filesync-plugin</artifactId>
        <configuration>
          <mappings>
            <mapping>
              <sourceFolder>src/main/resources</sourceFolder>
              <destinationFolder>@../target/tomcat${cargo.tomcat.major.version}x/webapps/site/WEB-INF/classes</destinationFolder>
            </mapping>
            <mapping>
              <sourceFolder>src/main/webapp</sourceFolder>
              <destinationFolder>@../target/tomcat${cargo.tomcat.major.version}x/webapps/site</destinationFolder>
            </mapping>
          </mappings>
        </configuration>
      </plugin>

${project.basedir}/conf/site-context.xml(我试过将两个路径都设置为空字符串和“/”,但均无效)

<?xml version="1.0" encoding="UTF-8"?>
<Context path="/" docBase="${project.basedir}/site/target/ROOT">

    <Loader className="org.apache.catalina.loader.VirtualWebappLoader" searchVirtualFirst="true"
            virtualClasspath="${project.basedir}/site/target/classes" />

</Context>

因为您将已部署的应用程序重命名为 ROOT,您可能还需要将站点名称 -context.xml 更改为 ROOT.xml。根据 Tomcat context docs 需要匹配 war 文件名。

<plugin>
  <groupId>org.codehaus.cargo</groupId>
  <artifactId>cargo-maven2-plugin</artifactId>
  <configuration>
    <configuration>
      <properties>
        <cargo.jvmargs>-Xmx1920m -Xdebug -Xrunjdwp:transport=dt_socket,address=${cargo.debug.address},server=y,suspend=${cargo.debug.suspend} -noverify -javaagent:/Users/eric/libs/springloaded.jar ${cargo.jvm.args}</cargo.jvmargs>
      </properties>
      <configfiles>
        <configfile>
          <file>${project.build.directory}/contexts/site-context.xml</file>
          <todir>conf/Catalina/localhost/</todir>
          <tofile>ROOT.xml</tofile>
        </configfile>
      </configfiles>
    </configuration>
  </configuration>
</plugin>