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
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
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
  1. DZone
  2. Coding
  3. Frameworks
  4. Managing Spring Boot Apps Locally With Trampoline

Managing Spring Boot Apps Locally With Trampoline

Trampoline is an incredibly useful tool, so let's take it for a spin with some microservices to see what it offers for those.

Piotr Mińkowski user avatar by
Piotr Mińkowski
CORE ·
Jun. 10, 18 · Tutorial
Like (9)
Save
Tweet
Share
6.54K Views

Join the DZone community and get the full member experience.

Join For Free

Today, I came across an interesting solution for managing Spring Boot applications locally – Trampoline. It is a rather simple product that provides a web console allowing you to start, stop, and monitor your application. It can also sometimes be useful if you run many different applications locally during microservices development. In this article, I’m going to show the main features provided by Trampoline.

How it Works

Trampoline is also Spring Boot application, so you can easily start it using your IDE or with a java -jar command after building the project with mvn clean install. By default, the web console is available on port 8080, but you can easily override it with the server.port parameter. It allows you to:

  • Start your application: You can do that by running the Maven Spring Boot plugin command mvn spring-boot:run that builds the binary from source code and runs a Java application.
  • Shut down your application: You can do that by calling the Spring Boot Actuator /shutdown endpoint, which performs a graceful shutdown of your application
  • Monitor your application: You can have it display some basic information retrieved from Spring Boot Actuator endpoints like traces, logs, metrics, and Git commit data.

Setup

First, you need to clone the Trampoline repository from GitHub. It is available here: https://github.com/ErnestOrt/Trampoline.git. The application is available inside the trampoline directory. You can run its main class Application or just run the Maven command mvn spring-boot:run. And that is all. Trampoline is available under the address http://localhost:8080.

Configuring Applications

We will use one of my previous sample of microservices built with Spring Boot 2.0. It is available on my GitHub account in the repository sample-spring-microservices-new available here: https://github.com/piomin/sample-spring-microservices-new.git. Before deploying these microservices on Trampoline, we need to perform some minor changes. First, all the microservices have to expose Spring Boot Actuator endpoints. Be sure that the endpoint /shutdown is enabled. All changes should be performed in Spring Boot YAML configuration files, which are stored on config-service.

management:
  endpoint.shutdown.enabled: true
  endpoints.web.exposure.include: '*'


If you would like to provide information about the last commit, you should include the Maven plugin git-commit-id-plugin, which is executed during the application build. Of course, you also need to add the spring-boot-maven-plugin plugin, which is used for building and running Spring Boot applications from Maven. All the required changes are available in the branch trampoline (https://github.com/piomin/sample-spring-microservices-new/tree/trampoline).

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
        <plugin>
            <groupId>pl.project13.maven</groupId>
            <artifactId>git-commit-id-plugin</artifactId>
        </plugin>
    </plugins>
</build>


Adding Microservices

The further configuration will be provided using the Trampoline web console. First, go to the section SETTINGS. You need to register every single instance of your microservices. You can register a(n):

  • External, already running application by providing an IP address and HTTP port.
  • Git repository with your microservice, which then will be cloned into your machine.
  • Git repository with your microservice existing on the local machine just by providing its location.

I have cloned the repository with my microservices by myself, so I’m selecting the third choice. Inside the Register Microservice form, we have to set the microservice name, port, actuator endpoint context path, default build tool, and Maven pom.xml file location.

trampoline-1

It is important to remember setting the Maven home location in the panel Maven Settings. After registering all sample microservices (config-service, discovery-service, gateway-service, and three Spring Cloud applications), we may add them to one group. It is a very useful feature because then we could deploy them all with one click.

trampoline-2

Here’s the full list of services registered in Trampoline.

trampoline-3

Managing Microservices

Now we can navigate to the section INSTANCES. We can launch single instances of microservices or a group of microservices. If you would like to launch a single instance, just select it from the list on the Launch Instance panel and click the button Launch. It immediately starts a new command window, builds your application from source code, and launches it under your selected port.

trampoline-4

The list of running microservices is available below. You can see the application’s HTTP port and status. You may also display traces, logs, or metrics by clicking on one of icons available in every row.

trampoline-5

Here’s information about the last commit for discovery-service.

trampoline-6

If you decide to restart an application, Trampoline sends the request to the /shutdown endpoint, rebuilds your application with the newest version of your code, and runs it again. Alternatively, you may use Spring Boot Devtools (by including the dependency org.springframework.boot:spring-boot-devtools), which forces your application to be restarted after source code modification. Because Trampoline is continuously monitoring the status of all registered applications by calling its actuator endpoints, you will still see the full list of running microservices.

Spring Framework Spring Boot application microservice

Published at DZone with permission of Piotr Mińkowski, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Three SQL Keywords in QuestDB for Finding Missing Data
  • Top Five Tools for AI-based Test Automation
  • Agile Scrum and the New Way of Work in 2023
  • Silver Bullet or False Panacea? 3 Questions for Data Contracts

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

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

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: