DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Apache Cassandra combines the benefits of major NoSQL databases to support data management needs not covered by traditional RDBMS vendors.

The software you build is only as secure as the code that powers it. Learn how malicious code creeps into your software supply chain.

Generative AI has transformed nearly every industry. How can you leverage GenAI to improve your productivity and efficiency?

Related

  • How to Import the Gradle Spring Boot Application in Eclipse? | Spring Boot Tutorial [Video]
  • Introduce a New API Quickly Using Spring Boot and Gradle
  • Actuator Enhancements: Spring Framework 6.2 and Spring Boot 3.4
  • How Spring Boot Starters Integrate With Your Project

Trending

  • The End of “Good Enough Agile”
  • SaaS in an Enterprise - An Implementation Roadmap
  • Modern Test Automation With AI (LLM) and Playwright MCP
  • How to Merge HTML Documents in Java
  1. DZone
  2. Coding
  3. Frameworks
  4. Continuous Auto-restart With Spring Boot DevTools and Gradle

Continuous Auto-restart With Spring Boot DevTools and Gradle

Couple Gradle's continuous build feature with the recently-released Spring Boot 1.3's DevTools, and you've got continuous auto-restarting.

By 
Davor Sauer user avatar
Davor Sauer
·
Dec. 09, 15 · Tutorial
Likes (5)
Comment
Save
Tweet
Share
39.3K Views

Join the DZone community and get the full member experience.

Join For Free

With the recent release of Spring Boot 1.3, there is a new dependency in town: Spring Boot DevTools. Which enables us to automatically restart Spring Boot applications if some classes in the class path have changed.

This is quite handy for local development, but still, you need to trigger the build phase to recompile the class. In this case, we can use Gradle's continuous build feature and automatically rebuild our project. Spring Boot DevTools will pick up the changes and restart application.

One way to do this is to add the necessary dependencies to your build.gradle. In this example, the DevTool dependency is added only when we run the bootRun task (devconfiguration). There are other features of DevTool that can be useful during development, and at other times as well. So it's up to you on how you want to organize your project.

buildscript {
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:1.3.0.RELEASE")
    }
    repositories {
        mavenCentral()
    }
}

apply plugin: 'java'
apply plugin: 'spring-boot'

repositories {
    mavenCentral()
}

configurations {
    dev
}

dependencies {
    compile("org.springframework.boot:spring-boot-starter-web:1.3.0.RELEASE")
    compile 'org.slf4j:slf4j-api:1.7.13'

    dev("org.springframework.boot:spring-boot-devtools")
}

bootRun {
    // Use Spring Boot DevTool only when we run Gradle bootRun task
    classpath = sourceSets.main.runtimeClasspath + configurations.dev
}

After this, we just need to open two terminals:

  1. At the first terminal, start Gradle build as a continuous task: gradle build --continuous
  2. At the second terminal, start the Gradle bootRun task: gradle bootRun

Image title

A working example can be found here.


Spring Framework Spring Boot Gradle

Published at DZone with permission of Davor Sauer. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • How to Import the Gradle Spring Boot Application in Eclipse? | Spring Boot Tutorial [Video]
  • Introduce a New API Quickly Using Spring Boot and Gradle
  • Actuator Enhancements: Spring Framework 6.2 and Spring Boot 3.4
  • How Spring Boot Starters Integrate With Your Project

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!