为什么我的Spring mvc Web应用程序有两个不同的Project Context?

时间:2014-10-05 09:39:08

标签: eclipse spring maven spring-mvc web

以下是我的pom.xml

<project xmlns="Page on apache.org" xmlns:xsi="Page on w3.org"
xsi:schemaLocation="Welcome to Apache Maven/POM/4.0.0 Page on apache.org">
<modelVersion>4.0.0</modelVersion>
<groupId>com.MyStartUp.www</groupId>
<artifactId>MyStartUp</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>MyStartUp Maven Webapp</name>
<url>Welcome to Apache Maven</url>
<properties>
<spring.version>4.0.2.RELEASE</spring.version>

</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb</artifactId>
<version>1.6.0.RELEASE</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-api</artifactId>
<version>2.2.1</version>
</dependency>
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-core</artifactId>
<version>2.2.1</version>
</dependency>
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-jsp</artifactId>
<version>2.2.1</version>
</dependency>
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-servlet</artifactId>
<version>2.2.1</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.1.2</version>
</dependency>
</dependencies>
<build>
<finalName>MyStartUp</finalName>

<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>

我使用tomcat服务器v7.0进行部署,并使用maven进行构建。

每当我进行更改时,我都会转到maven终端并使用“mvn clean install”并转到localhost:8080/manager并通过浏览桌面上的应用程序来部署战争。在此之后,我在浏览器的tomcat管理器窗口中看到“MyStartUp”。

我在eclipse中的项目名称看起来像是“mystartup”。

当我在右键单击服务器后使用“添加或删除”在Eclipse IDE中添加项目时,我看到“mystartup”并添加它。然后,如果我刷新localhost:8080/manager/

我看到部署了两个不同的项目。 1)MyStartUp(网址:localhost:8080 / MyStartUp - &gt; Works) 2)mystartup(网址:localhost:8080 / mystartup - &gt;不起作用)

当我点击第二个时,我无法访问该应用程序。但如果我使用第一个,它就可以了

因此,每次,我在IDE中执行“mvn clean install”并手动取消部署“MyStartUp”并部署新安装的“MyStartUp”。这会占用我的时间。我想在IDE中将我的项目添加到Server并在我进行更改并运行应用程序时重新启动它。如何解决这个问题?

PS:

这是我的web.xml

<web-app version="2.2" id="WebApp_ID">

    <!-- <display-name>Archetype Created Web Application</display-name> -->

    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/spring/appContext.xml</param-value>
    </context-param>

    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener
        </listener-class>
    </listener>

    <servlet>
        <servlet-name>dispatcher</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet
        </servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>/WEB-INF/spring/dispatcher-servlet.xml</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>dispatcher</servlet-name>
        <url-pattern>/mvc/*</url-pattern>
    </servlet-mapping>
    <welcome-file-list>
        <welcome-file>/WEB-INF/jsp/template.jsp</welcome-file>  
    </welcome-file-list>
</web-app>

这就是我的git clone看起来的样子

git clone https://MyStartUp@bitbucket.org/MyStartUp/mystartup.git

0 个答案:

没有答案