0

在我最近切换到以 root 身份部署之前,Spring 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>
4

1 回答 1

2

因为您将部署的应用程序重命名为 ROOT,您可能还需要将 site-context.xml 的名称更改为 ROOT.xml。根据Tomcat 上下文文档,它需要匹配战争文件名。

<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>
于 2015-05-01T12:16:27.067 回答