带有Maven的Tomcat7,contextReloadable未得到应用 [英] Tomcat7 with maven, contextReloadable not getting applied
问题描述
在我的pom.xml
中,我具有以下个人资料:
In my pom.xml
, I have the following profile :
<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:
I am running tomcat with the following command from my command line:
mvn clean tomcat7:run -Plocal
除了我编辑和保存Java文件(使用intellij)时,一切都很好,没有任何反应.该应用程序根本不会重新加载.我尝试过等待和刷新,但没有任何效果.
Everything works great except when I edit and save my java files (using intellij) nothing happens. The app doesn't reload at all. I have tried waiting and refreshing, but nothing has worked.
有什么想法吗?
这是我的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>
推荐答案
这是一个简单的解决方法.如果有人遇到同样的问题,我将与他人分享.问题是Intellij没有编译Java文件.
Well it was a simple fix. Ill share it if anyone has the same problem. The problem was Intellij was not compiling the java files.
要使其正常工作,我必须去Build->Compile... (ctrl+Shift+F9)
.
To get this to work, I had to go Build->Compile... (ctrl+Shift+F9)
.
或者,您可以转到File ->Settings->Compiler->make project automatically
,Intellij会自动执行.
Or, you can go to File ->Settings->Compiler->make project automatically
and Intellij will do it automatically.
这篇关于带有Maven的Tomcat7,contextReloadable未得到应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!