2012-08-24 82 views
1

我目前正在使用Spring Roo构建一个相当简单的webapp。但是,似乎Spring应用程序默认部署为“/ {app name}”,而不是“/”作为顶级目录。也就是说,控制器由“/ {app name}/person”映射,而不是“/ person”。经过相当长的时间后,我看不到这将被修复。这是一个设置的地方?Spring Roo“Base”URL

+1

嗨亚伦,因为你是新来的StackOverflow,我对你有一点提示:如果你把问题称为一个问题,并且如果你把所有的名字都包含在其中。如果可能的话,最好不要在问题中使用“it”。例如:“我如何更改Spring Roo”的“基本URL”?只是一个小小的提示。 –

回答

0

假设您的Spring Roo应用程序在Apache Tomcat上运行,您可以执行的操作是配置Tomcat Root上下文。

您可以通过以下方式进行此操作。

  1. 定义中的conf一个的ROOT.xml上下文文件/卡塔利娜/本地主机
  2. 名称你的web应用WAR“ROOT.war”或包含文件夹“ROOT”

更多信息可以在找到以下链接。

http://benhutchison.wordpress.com/2008/07/30/how-to-configure-tomcat-root-context/

干杯!

2

基本路径由应用程序服务器定义,而不是应用程序本身。 在pom.xml,覆盖以下插件:

Maven的战争插件 - MVN包,MVN的tomcat:运行战争

 <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-war-plugin</artifactId> 
      <version>2.2</version> 
      <configuration> 
       <warName>ROOT</warName> 
       <!-- exclude test files from war package --> 
       <packagingExcludes>src/test/**</packagingExcludes> 
      </configuration> 
     </plugin> 

Tomcat的Maven的插件 - MVN tomcat的:运行

 <plugin> 
      <groupId>org.codehaus.mojo</groupId> 
      <artifactId>tomcat-maven-plugin</artifactId> 
      <version>1.1</version> 
      <configuration> 
       <path>/</path> 
      </configuration> 
     </plugin> 

org.mortbay.jetty - 命令mvn码头:运行

 <plugin> 
      <groupId>org.mortbay.jetty</groupId> 
      <artifactId>jetty-maven-plugin</artifactId> 
      <version>8.0.4.v20111024</version> 
      <configuration> 
       <webAppConfig> 
        <contextPath>/</contextPath> 
       </webAppConfig> 
      </configuration> 
     </plugin>