【问题标题】:Tomcat7 with maven, contextReloadable not getting applied带有maven的Tomcat7,contextReloadable没有得到应用
【发布时间】:2015-03-23 04:36:29
【问题描述】:

在我的pom.xml 中,我有以下个人资料:

      <profile>
        <id>local</id>
        <build>
            <finalName>webProject</finalName>
            <plugins>
            <plugin>
                <groupId>org.apache.tomcat.maven</groupId>
                <artifactId>tomcat7-maven-plugin</artifactId>
                <version>2.2</version>
                <configuration>
                    <path>/</path>
                    <contextReloadable>true</contextReloadable>
                </configuration>
            </plugin>
            </plugins>
        </build>
    </profile>

我正在使用命令行中的以下命令运行 tomcat:

mvn clean tomcat7:run -Plocal

一切都很好,除了我编辑和保存我的 java 文件(使用 intellij)没有任何反应。该应用程序根本不会重新加载。我尝试过等待和刷新,但没有任何效果。

有什么想法吗?

这是我的web.xml

<web-app xmlns="http://java.sun.com/xml/ns/javaee"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
      http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
     version="2.5">
<display-name>Archetype Created Web Application</display-name>

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

<servlet-mapping>
    <servlet-name>webProject</servlet-name>
    <url-pattern>/</url-pattern>
</servlet-mapping>

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

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

【问题讨论】:

    标签: java maven tomcat intellij-idea tomcat7


    【解决方案1】:

    嗯,这是一个简单的修复。如果有人有同样的问题,我会分享它。问题是 Intellij 没有编译 java 文件。

    为了让它工作,我必须去Build-&gt;Compile... (ctrl+Shift+F9)

    或者,您可以转到File -&gt;Settings-&gt;Compiler-&gt;make project automatically,Intellij 会自动完成。

    【讨论】:

    • InteliJ 可以理解字节码类是否有变化,而不是源代码。因此,当您运行手动编译或运行测试时,InteliJ 进行编译并发现有更改并触发重新编译。否则什么都不会发生。
    猜你喜欢
    • 2012-12-18
    • 1970-01-01
    • 2013-06-17
    • 2012-04-13
    • 2014-01-11
    • 2015-02-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多