Akhil K Nambiar
Akhil K Nambiar

Reputation: 3975

dev mode in spring MVC

Is there any development mode in Spring like in Struts. In Struts if we set dev mode to true all the configuration files are loaded in every request. However now when I'm developing in Spring MVC, I have to restart server after every change. Or is there some other method by which I can force reload.

Upvotes: 14

Views: 5634

Answers (5)

F4b3r
F4b3r

Reputation: 63

If you are using Spring Boot, then all you need to do is add the dependency devtools to your project. This allow you to have your application deployed each time you modify a classpath file.

maven

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-devtools</artifactId>
        <optional>true</optional>
    </dependency>
</dependencies>

Gradle:

dependencies {
    compileOnly("org.springframework.boot:spring-boot-devtools")
}

Spring docs: Spring boot devtools

Upvotes: 0

JJ Zabkar
JJ Zabkar

Reputation: 3689

Yes: If you are using Tomcat or a derivative (VMWare vFabric tc Server), you can configure application reload behavior (hot deploy). This allows changes to say a method to be reloaded without restart. The key is to set:

  1. Publishing set to Automatically publish when resources change
  2. Your web module set to Auto Reload disabled.

VMWare vFabric tc Server 2.6+ (packaged with STS 2.9+) provides two options:

  • Java Agent-based reloading
  • JMX-based reloading

Upvotes: 0

Rafael Sanches
Rafael Sanches

Reputation: 1823

What change you refer to? Template changes?

Even with struts, JSP and velocity templates shouldn't reload the servlet container. Only Java classes would do that.

I have written a blog post Spring-mvc + Velocity + DCEVM about how to use Spring + Velocity + Dynamic Code Evolution VM (DCEVM) in order to not restart the server when developing:

Upvotes: 0

ŁukaszBachman
ŁukaszBachman

Reputation: 33735

Answering both of your questions and keeping it short.

No, there is nothing like a devmode in Spring framework so you can throw it out of your head.

Yes, you could skip reloading by using some bytecode manipulation techniques. You can use either:

  • external tool (like JRebel or Javaleon)
  • server with hot deployment (like Jetty)
  • IDE (some IDEs offer such functionalities as well)

Hope that helps.

Upvotes: 4

Ralph
Ralph

Reputation: 120811

No there is no such configuration for Spring MVC. But it is a good idea for an feature request.

Upvotes: 8

Related Questions